Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tar file completion not working as expected under various option combinations #1194

Open
dahart opened this issue May 14, 2024 · 0 comments
Open

Comments

@dahart
Copy link

dahart commented May 14, 2024

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

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

Debug trace

tar-completion.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant