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: Complete adding files to archive with long options #1195

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yedayak
Copy link
Contributor

@yedayak yedayak commented May 17, 2024

Fixes: #98

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
Copy link
Collaborator

@akinomyoga akinomyoga left a 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?

@yedayak
Copy link
Contributor Author

yedayak commented May 21, 2024

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

@yedayak
Copy link
Contributor Author

yedayak commented May 23, 2024

Added a commit that removes the FIXMEs by keeping track of compression long options

completions/tar Outdated
Comment on lines 476 to 505
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
Copy link
Owner

@scop scop Jun 1, 2024

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

Copy link
Owner

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 👍

Copy link
Contributor Author

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.

@yedayak yedayak force-pushed the tar-long-options branch 4 times, most recently from 6e2e338 to 401cb5d Compare June 2, 2024 18:43
completions/tar Outdated Show resolved Hide resolved
completions/tar Outdated Show resolved Hide resolved
completions/tar Outdated Show resolved Hide resolved
completions/tar Outdated Show resolved Hide resolved
@yedayak yedayak force-pushed the tar-long-options branch 2 times, most recently from 1c3d16c to 33bd66a Compare June 2, 2024 19:08
completions/tar Outdated Show resolved Hide resolved
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>
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

Successfully merging this pull request may close these issues.

long option support for tar broken with version 2.4
3 participants