Exit codes, stderr suppression, minor edits (#788)
This is a re-attempt of #643 - `[ "$archive" = "" ]` may be replaced with `[ -z "$archive" ]` - added exit codes - upon entering `ext -c` with no arguments stderr will be thrown from readlink, should be suppressed
This commit is contained in:
parent
5fd9637eb7
commit
ca9b3952e6
1 changed files with 4 additions and 4 deletions
|
@ -8,19 +8,19 @@
|
||||||
|
|
||||||
while getopts "hc" o; do case "${o}" in
|
while getopts "hc" o; do case "${o}" in
|
||||||
c) extracthere="True" ;;
|
c) extracthere="True" ;;
|
||||||
*) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit ;;
|
*) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit 1 ;;
|
||||||
esac done
|
esac done
|
||||||
|
|
||||||
if [ -z "$extracthere" ]; then
|
if [ -z "$extracthere" ]; then
|
||||||
archive="$(readlink -f "$*")" &&
|
archive="$(readlink -f "$*")" &&
|
||||||
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
|
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
|
||||||
mkdir -p "$directory" &&
|
mkdir -p "$directory" &&
|
||||||
cd "$directory" || exit
|
cd "$directory" || exit 1
|
||||||
else
|
else
|
||||||
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)")"
|
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)" 2>/dev/null)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ "$archive" = "" ] && printf "Give archive to extract as argument.\\n" && exit
|
[ -z "$archive" ] && printf "Give archive to extract as argument.\\n" && exit 1
|
||||||
|
|
||||||
if [ -f "$archive" ] ; then
|
if [ -f "$archive" ] ; then
|
||||||
case "$archive" in
|
case "$archive" in
|
||||||
|
|
Loading…
Reference in a new issue