From 1f2b734fd7f80c8c9ac5b3ca52b417cae4443adf Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 25 Jan 2022 13:54:50 +0100 Subject: [PATCH] bin/ex: readd support for zips on systems without 7zip --- .local/bin/scripts/ex | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.local/bin/scripts/ex b/.local/bin/scripts/ex index 6cd0486..8d83cf7 100755 --- a/.local/bin/scripts/ex +++ b/.local/bin/scripts/ex @@ -19,8 +19,11 @@ for arg do (*.tar.*|*.tar) tar --extract --file "$path";; (*.tbz2) tar xjf "$path" ;; (*.tgz) tar xzf "$path" ;; - #(*.zip|*.jar) unzip "$path" | rewrite ;; - (*.7z|*.z01|*.zip|*.jar) 7z x "$path" ;; + (*.7z|*.z01|*.zip|*.jar) + if which 7z >/dev/null + then 7z x "$path" + else unzip "$path" | rewrite + fi;; (*.gz) gunzip "$path" ;; (*.bz2) bunzip2 "$path" ;; (*.rar) unrar x "$path" ;; @@ -30,7 +33,7 @@ for arg do (*) echo "'$arg' cannot be extracted by ex" >&2;; esac test "$(basename "$PWD")" = "$namepart" && - if test $# -lt 2 && "$(ls -U | wc -l)" -lt 3 + if test $# -lt 2 -a "$(ls -U | wc -l)" -lt 3 then mv * .. && cd .. && rm -d "$namepart" else cd .. && mv "$namepart" "$name" fi