diff options
| author | Teddy Wing | 2016-07-21 22:42:10 -0400 |
|---|---|---|
| committer | Teddy Wing | 2016-07-21 22:42:10 -0400 |
| commit | 7de785f2f7ad0387f56323f6f14a67357293651f (patch) | |
| tree | 19031b4d63b036dc2875d8269305d753e1e189a7 | |
| parent | 65a0fbd001f5cec3f90441b2a25da3fe32afc2ef (diff) | |
| download | qcd-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-x | qcd | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 () { |
