diff --git a/commands/unziptar b/commands/unziptar index b2a901058..9792ca7a5 100755 --- a/commands/unziptar +++ b/commands/unziptar @@ -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"