#1038721 /usr/share/bash-completion/completions/tar: tar -f completion starts suggesting directories but stops at first space

#1038721#5
Date:
2023-06-20 13:42:34 UTC
From:
To:
Dear Maintainer,

Consider the following
  $ ls -l
  drwx------  5 nabijaczleweli users   140 Jun 17 19:28 'SunOS 2.0 (Tape) [Sun-2]'
  drwx------  6 nabijaczleweli users   140 Mar 13  2016 'SunOS 3.2 (Tape) [Sun-2]'
  drwx------  7 nabijaczleweli users   160 Mar 13  2016 'Sun UNIX 4.2 Release 3.5 (Tape) [Sun-2]'
  $ tar -tvaf S
  SunOS 2.0 (Tape) [Sun-2]/                SunOS 3.2 (Tape) [Sun-2]/                Sun UNIX 4.2 Release 3.5 (Tape) [Sun-2]/ SysVr1234/
  $ tar -tvaf S
  SunOS 2.0 (Tape) [Sun-2]/                SunOS 3.2 (Tape) [Sun-2]/                Sun UNIX 4.2 Release 3.5 (Tape) [Sun-2]/ SysVr1234/
  $ tar -tvaf Sun
  SunOS 2.0 (Tape) [Sun-2]/                SunOS 3.2 (Tape) [Sun-2]/                Sun UNIX 4.2 Release 3.5 (Tape) [Sun-2]/
  $ tar -tvaf SunOS\   # there's a space after the backslash
and further tabbing no longer does anything, neither does typing in 3 or
2 then tabbing.

  tar -tvaf 'SunOS 3.2 (Tape) [Sun-2]'/
completes to
  tar -tvaf SunOS\ 3.2\ \(Tape\)\ \[Sun-2\]/tape
but then stops again.

If I set -x, I see
  ++ compgen -f -X '!*.@(@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)|zst))|t@([abglx]z|b?(z)2|zst))|@(@(TAR|GEM|SPKG)?(.@(Z|[BGX]Z|BZ2|LZ?(MA|O)|ZST))|T@([ABGLX]Z|B?(Z)2|ZST)))' -o plusdirs -- 'SunOS 3.2 (Tape) [Sun-2]'\''/'
the first time and
  ++ compgen -f -X '!*.@(@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)|zst))|t@([abglx]z|b?(z)2|zst))|@(@(TAR|GEM|SPKG)?(.@(Z|[BGX]Z|BZ2|LZ?(MA|O)|ZST))|T@([ABGLX]Z|B?(Z)2|ZST)))' -o plusdirs -- 'SunOS\\\ 3.2\\\ \\\(Tape\\\)\\\ \\\[Sun-2\\\]/tape'
the second. Unclear to me why or how, since the word being completed is
in both cases the same.

Best,
наб