Skip to content

Commit

Permalink
unziptar: better handling of unziptar deps
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Sep 1, 2023
1 parent 88a5f99 commit 23d187a
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions commands/unziptar
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,30 @@ function unziptar() (
cp -Rfv "$@"
}
elif test "$format" = 'zip'; then
setup-util-unziptar --quiet
unzip -u "$archive"
# be cautious with unziptar dependency, as is challenging on fresh macos
if command-missing unzip; then
setup-util-unziptar --quiet
fi
unzip -u "$archive" 2>/dev/null || {
setup-util-unziptar --quiet
unzip -u "$archive" || {
echo-error "Failed to extract the archive:" $'\n' "$(file "$archive")"
return 1
}
}
elif test "$format" = 'tar'; then
setup-util-unziptar --quiet
# be cautious with unziptar dependency, as is challenging on fresh macos
if command-missing tar; then
setup-util-unziptar --quiet
fi
# don't use -z flag, as that enforces gzip (tar.xy) which is not valid for (.tar.xz)
# without -z, auto-detection is used
tar -xvf "$archive" || {
echo-error "Failed to extract the archive:" $'\n' "$(file "$archive")"
return 1
tar -xvf "$archive" 2>/dev/null || {
setup-util-unziptar --quiet
tar -xvf "$archive" || {
echo-error "Failed to extract the archive:" $'\n' "$(file "$archive")"
return 1
}
}
else
help "Unrecognised format: $format"
Expand Down

0 comments on commit 23d187a

Please sign in to comment.