aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-07-21 22:42:10 -0400
committerTeddy Wing2016-07-21 22:42:10 -0400
commit7de785f2f7ad0387f56323f6f14a67357293651f (patch)
tree19031b4d63b036dc2875d8269305d753e1e189a7
parent65a0fbd001f5cec3f90441b2a25da3fe32afc2ef (diff)
downloadqcd-7de785f2f7ad0387f56323f6f14a67357293651f.tar.bz2
qcd: Only run `cd` if the given shortcut exists
If we don't check that the shortcut exists before trying to `cd`, we end up in the HOME directory, which is not what we want. We just want the `qcd` command to fail silently.
-rwxr-xr-xqcd10
1 files changed, 6 insertions, 4 deletions
diff --git a/qcd b/qcd
index 58740ec..25ce7e1 100755
--- a/qcd
+++ b/qcd
@@ -66,10 +66,12 @@ function remove_shortcut () {
function change_directory () {
local shortcut=$1
- cd $(awk -v shortcut="$shortcut" '{
- if ($1 == shortcut)
- { print $2 }
- }' $QCD_DATABASE_FILE)
+ if shortcut_exists $shortcut; then
+ cd $(awk -v shortcut="$shortcut" '{
+ if ($1 == shortcut)
+ { print $2 }
+ }' $QCD_DATABASE_FILE)
+ fi
}
function qcd () {