You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Filename completion isn't working with tar in some cases where I expect it to work.
When extracting from an archive with tar's "traditional" option style (block of option letters with a dash), filename completion only works when 'f' is the last option letter in the options block, even though tar does not require the f argument to be last (see the tar man page for an example). I usually type something like "tar -xfvz file..." from muscle memory. This has been bugging me for years and I only just realized what's going on by trying all 24 letter permutations and mapping which ones work. :P Would it be relatively easy to allow "tar -xfvz ar" to complete filenames? In this case, completion is empty, so a fallback question might be can filenames be completed by default when there is no other completion?
I see the comment in completions/tar about advising to use a dash before the option block, but it would be extra nice if tar completion worked with the no-dash option block too. After all, tar supports the no-dash style and does not advise against it's use. Are there technical limitations?
When creating an archive, it seems filename completion of the archive with an existing name doesn't work even when the 'f' option is last or is given in GNU long-style. One reason to support this is when intentionally overwriting an archive. (It's not uncommon for me to have to create an archive several times before I get it right.) Another reason is when working on multiple tar files with a common prefix. A third, perhaps, is just to see that completion is working. Is the reason to disallow filename completion of the archive for safety? Are there other reasons not to complete existing filenames when creating an archive?
To reproduce
touch archive.tar
touch archive.tgz
tar -xfv ar<TAB> (nothing happens. Expect completion with archive.{tar,tgz} or archive.tar)
tar -xfvz ar<TAB> (nothing happens. Expect completion with archive.{tar,tgz} or archive.tgz)
tar -cfv ar<TAB> (nothing happens. Expect completion with archive.{tar,tgz} or archive.tar)
Would love if no-dash traditional options were also supported:
tar xfvz ar<TAB> (nothing happens. Expect same completion as tar -xvzf ar<TAB>)
tar cfvz ar<TAB> (nothing happens. Expect same completion as tar -cvzf ar<TAB>)
tar cfvz archive.tgz <TAB> (Completes directories only. Expect completion of files and directories, should be same behavior as tar -cfvz archive.tgz <TAB>)
Versions (please complete the following information)
- [ ] Operating system name/distribution and version: Linux 5.15.0-105-generic #115~20.04.1-Ubuntu SMP Mon Apr 15 17:33:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
- [ ] bash version, `echo "$BASH_VERSION"`: 5.0.17(1)-release
- [ ] bash-completion version, `(IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}")`: 2.14.0
Describe the bug
Filename completion isn't working with tar in some cases where I expect it to work.
When extracting from an archive with tar's "traditional" option style (block of option letters with a dash), filename completion only works when 'f' is the last option letter in the options block, even though tar does not require the f argument to be last (see the tar man page for an example). I usually type something like "tar -xfvz file..." from muscle memory. This has been bugging me for years and I only just realized what's going on by trying all 24 letter permutations and mapping which ones work. :P Would it be relatively easy to allow "tar -xfvz ar" to complete filenames? In this case, completion is empty, so a fallback question might be can filenames be completed by default when there is no other completion?
I see the comment in completions/tar about advising to use a dash before the option block, but it would be extra nice if tar completion worked with the no-dash option block too. After all, tar supports the no-dash style and does not advise against it's use. Are there technical limitations?
When creating an archive, it seems filename completion of the archive with an existing name doesn't work even when the 'f' option is last or is given in GNU long-style. One reason to support this is when intentionally overwriting an archive. (It's not uncommon for me to have to create an archive several times before I get it right.) Another reason is when working on multiple tar files with a common prefix. A third, perhaps, is just to see that completion is working. Is the reason to disallow filename completion of the archive for safety? Are there other reasons not to complete existing filenames when creating an archive?
To reproduce
Versions (please complete the following information)
Debug trace
tar-completion.log
The text was updated successfully, but these errors were encountered: