bin/ex: automatically use subdirectory
This commit is contained in:
parent
118f11386f
commit
ebe7a6992b
|
@ -1,8 +1,14 @@
|
||||||
#!/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
|
||||||
|
arg="$(realpath "$arg")"
|
||||||
|
name="$(basename "${arg%.*}")"
|
||||||
|
if test "$(ls -U | wc -l)" -gt 2; then
|
||||||
|
mkdir "$name"
|
||||||
|
cd "$name"
|
||||||
|
fi
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
*.tar.bz2) tar xjf "$arg" ;;
|
*.tar.bz2) tar xjf "$arg" ;;
|
||||||
*.tar.*|*.tar) tar --extract --file "$arg";;
|
*.tar.*|*.tar) tar --extract --file "$arg";;
|
||||||
|
|
Loading…
Reference in New Issue