bin/ex: automatically use subdirectory
This commit is contained in:
parent
118f11386f
commit
ebe7a6992b
|
@ -1,24 +1,30 @@
|
||||||
#!/bin/sh
|
#!/bin/sh -e
|
||||||
# ex - archive extractor
|
# ex - archive extractor
|
||||||
# usage: ex <file>
|
# usage: ex <file>
|
||||||
for arg do
|
for arg do
|
||||||
if test -r "$arg"; then
|
if test -r "$arg"; then
|
||||||
case "$arg" in
|
arg="$(realpath "$arg")"
|
||||||
*.tar.bz2) tar xjf "$arg" ;;
|
name="$(basename "${arg%.*}")"
|
||||||
*.tar.*|*.tar) tar --extract --file "$arg";;
|
if test "$(ls -U | wc -l)" -gt 2; then
|
||||||
*.bz2) bunzip2 "$arg" ;;
|
mkdir "$name"
|
||||||
*.rar) unrar x "$arg" ;;
|
cd "$name"
|
||||||
*.gz) gunzip "$arg" ;;
|
fi
|
||||||
*.tbz2) tar xjf "$arg" ;;
|
case "$arg" in
|
||||||
*.tgz) tar xzf "$arg" ;;
|
*.tar.bz2) tar xjf "$arg" ;;
|
||||||
*.zip|*.jar) unzip "$arg" ;;
|
*.tar.*|*.tar) tar --extract --file "$arg";;
|
||||||
*.Z) uncompress "$arg";;
|
*.bz2) bunzip2 "$arg" ;;
|
||||||
*.7z) 7z x "$arg" ;;
|
*.rar) unrar x "$arg" ;;
|
||||||
*.deb) ar x "$arg" ;;
|
*.gz) gunzip "$arg" ;;
|
||||||
*.zst) unzstd "$arg" ;;
|
*.tbz2) tar xjf "$arg" ;;
|
||||||
*) echo "'$arg' cannot be extracted by ex" ;;
|
*.tgz) tar xzf "$arg" ;;
|
||||||
esac
|
*.zip|*.jar) unzip "$arg" ;;
|
||||||
else
|
*.Z) uncompress "$arg";;
|
||||||
echo "'$1' is not a readable file"
|
*.7z) 7z x "$arg" ;;
|
||||||
fi
|
*.deb) ar x "$arg" ;;
|
||||||
|
*.zst) unzstd "$arg" ;;
|
||||||
|
*) echo "'$arg' cannot be extracted by ex" ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo "'$1' is not a readable file"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue