bin/ex: readd support for zips on systems without 7zip

This commit is contained in:
xeruf 2022-01-25 13:54:50 +01:00
parent 07fade09c3
commit 1f2b734fd7
1 changed files with 6 additions and 3 deletions

View File

@ -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