3635d7cf7e300b5ba746c384fc3e87a35561e62d

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(universalarchive): make plugin zsh-only to fix `realpath` not found error

Fixes #9586

Diff

 1diff --git a/plugins/universalarchive/universalarchive.plugin.zsh b/plugins/universalarchive/universalarchive.plugin.zsh
 2index 5a661a5b0d8cc9eeb629930ef04208f5caf2bd90..b287c22b2ad3d37647bf5aa8a99781cd252010c5 100644
 3--- a/plugins/universalarchive/universalarchive.plugin.zsh
 4+++ b/plugins/universalarchive/universalarchive.plugin.zsh
 5@@ -10,28 +10,28 @@ Supported archive formats are:
 6 tlz (tar.lzma), txz (tar.xz), tZ (tar.Z), xz, Z, zip, and zst."
 7 
 8   if [[ $# -lt 2 ]]; then
 9-    echo >&2 "$usage"
10+    print -u2 -- "$usage"
11     return 1
12   fi
13 
14   local ext="$1"
15-  local input="$(realpath "$2")"
16+  local input="${2:a}"
17 
18   shift
19 
20   if [[ ! -e "$input" ]]; then
21-    echo >&2 "$input not found"
22+    print -u2 -- "$input not found"
23     return 1
24   fi
25 
26   # generate output file name
27   local output
28   if [[ $# -gt 1 ]]; then
29-    output="$(basename "${input%/*}")"
30+    output="${input:h:t}"
31   elif [[ -f "$input" ]]; then
32-    output="$(basename "${input%.[^.]*}")"
33+    output="${input:r:t}"
34   elif [[ -d "$input" ]]; then
35-    output="$(basename "${input}")"
36+    output="${input:t}"
37   fi
38 
39   # if output file exists, generate a random name
40@@ -44,7 +44,7 @@ tlz (tar.lzma), txz (tar.xz), tZ (tar.Z), xz, Z, zip, and zst."
41 
42   # safety check
43   if [[ -f "$output" ]]; then
44-    echo >&2 "output file '$output' already exists. Aborting"
45+    print -u2 -- "output file '$output' already exists. Aborting"
46     return 1
47   fi
48 
49@@ -65,6 +65,6 @@ tlz (tar.lzma), txz (tar.xz), tZ (tar.Z), xz, Z, zip, and zst."
50     Z)            compress -vcf               "${@}" > "${output}" ;;
51     zip)          zip -rull                   "${output}"   "${@}" ;;
52     zst)          zstd -c -T0                 "${@}" > "${output}" ;;
53-    *) echo >&2 "$usage"; return 1 ;;
54+    *) print -u2 -- "$usage"; return 1 ;;
55   esac
56 }