Fix unzip completions for non Info-ZIP versions

macOS and (AFAICT) most Linux distributions ship with the Info-ZIP
version of unzip, which has the `unzip -h` flag; but other
implementations of unzip do not necessarily have it (i.e. FreeBSD).

`unzip` under FreeBSD does not support `unzip -h`. Under both Linux and
FreeBSD, `unzip -v` presents the list of options, though. Using this
instead of `unzip -h` to detect the Debian-patched version of the
Info-ZIP unzip program.
This commit is contained in:
Mahmoud Al-Qudsi 2018-06-03 14:53:13 -05:00
parent 8de5af5f9e
commit f6a1bc1489

View File

@ -25,7 +25,7 @@ complete -c unzip -s K -d "keep setuid/setgid/tacky permissions"
complete -c unzip -s M -d "pipe through `more` pager"
# Debian version of unzip
if unzip -h | string match -eq Debian
if unzip -v 2>/dev/null | string match -eq Debian
# the first non-switch argument should be the zipfile
complete -c unzip -n '__fish_is_first_token' -xa '(__fish_complete_suffix .zip)'