-
Notifications
You must be signed in to change notification settings - Fork 374
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: Complete adding files to archive with long options #1195
base: main
Are you sure you want to change the base?
Conversation
Currently when using long options, we don't complete files to add to the archive, but show options. Handle long options in tar_mode to fix this. Fixes scop#98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes! I see FIXME
comments, but are you going to work on these within this PR?
I was thinking to create a separate PR for those, since they will require some more refactoring, and those FIXMEs are broken even before this PR. If you want I can try doing it in this PR |
Added a commit that removes the |
completions/tar
Outdated
if [[ $tar_mode_arg == *a* || $compression_mode == auto-compress ]]; then | ||
ext="$tars" | ||
elif [[ $tar_mode_arg == *z* || $compression_mode == gzip ]]; then | ||
ext='t?(ar.)gz' | ||
elif [[ $tar_mode_arg == *Z* || $compression_mode == compress ]]; then | ||
ext='ta@(r.Z|z)' | ||
elif [[ $tar_mode_arg == *[jy]* || $compression_mode == bzip2 ]]; then | ||
ext='t@(?(ar.)bz?(2)|b2)' | ||
elif [[ $tar_mode_arg == *J* || $compression_mode == xz ]]; then | ||
ext='t?(ar.)xz' | ||
fi | ||
elif [[ $tar_mode_arg == +([^ZzJjy])f && $compression_mode == none ]]; then | ||
: # Pass through using defaults above | ||
elif [[ $tar_mode_arg == *[Zz]*f || $compression_mode == gzip || $compression_mode == compress ]]; then | ||
ext='@(@(t?(ar.)|spkg.)@(gz|Z)|taz)' | ||
elif [[ $tar_mode_arg == *[jy]*f || $compression_mode == bzip2 ]]; then | ||
ext='@(t?(ar.)bz?(2)|spkg|tb2)' | ||
elif [[ $tar_mode_arg == *[J]*f || $compression_mode == xz ]]; then | ||
ext='@(@(tar|spkg).@(lzma|xz)|t[lx]z)' | ||
elif [[ $compression_mode == zstd ]]; then | ||
ext='t?(ar.)zst' | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be more readable turned into case $tar_mode_arg in
blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean putting if [[ $compression_mode ==
inside each case? Or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do case $tar_mode_arg:$compression_mode in
and match it to +([^ZzJjy])f:none
or *[Zz]*f:* | *:gzip | *:compress
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's even better 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did that, it conflicted a bit with the bsdtar change, so I put it in the same commit with the compression change.
6e2e338
to
401cb5d
Compare
1c3d16c
to
33bd66a
Compare
Previously we only used single letter options to decide what file extensions to complete for extracting archives, make it also consider long options (gnu style). Co-Authored-By: Koichi Murase <myoga.murase@gmail.com>
Fixes: #98