aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté <msabate@suse.com>2015-07-28 10:05:38 +0200
committerMiquel Sabaté <msabate@suse.com>2015-07-28 10:05:38 +0200
commitd63a1d032b89482eed19ee81e2efe802df20378b (patch)
treedf66074af485201c464d7cb7d7a6c0505a642b06
parent8b873f3d5e4b9f01634fdc886109d7ba90d2e545 (diff)
downloadg-d63a1d032b89482eed19ee81e2efe802df20378b.tar.gz
g-d63a1d032b89482eed19ee81e2efe802df20378b.zip
Added a proper exit code
-rw-r--r--g.sh11
1 files changed, 7 insertions, 4 deletions
diff --git a/g.sh b/g.sh
index 4713780..aa0f312 100644
--- a/g.sh
+++ b/g.sh
@@ -76,7 +76,7 @@ is_keyword() {
# The main function for this script.
g() {
- version="0.3.4"
+ version="0.3.5"
cmd="$1"
gfile=$HOME/.gfile
declare -A gshortcuts
@@ -103,12 +103,12 @@ g() {
path=$3
else
echo "usage: g add <name> [path]"
- return
+ return 1
fi
fi
if is_keyword $2; then
echo "Cannot use '$2': keyword."
- return
+ return 1
fi
get_shortcuts
gshortcuts[$2]=$path
@@ -117,7 +117,7 @@ g() {
rm)
if [ "$#" != "2" ]; then
echo "usage: g rm <name>"
- return
+ return 1
fi
get_shortcuts
unset gshortcuts[$2]
@@ -142,9 +142,12 @@ g() {
if [ -z ${gshortcuts[$cmd]} ]; then
echo -e "Unknown shortcut \`$cmd'.\n"
usage
+ return 1
else
cd ${gshortcuts[$cmd]}
fi
;;
esac
+
+ return 0
}