aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-07-21 23:10:07 -0400
committerTeddy Wing2016-07-21 23:11:16 -0400
commitf0189d6dc374b4238892e3309e116317a6d8c48c (patch)
tree00e2bea9d8e3fee3b0014c1525a7de1f5a10b4f9
parent7de785f2f7ad0387f56323f6f14a67357293651f (diff)
downloadqcd-f0189d6dc374b4238892e3309e116317a6d8c48c.tar.bz2
qcd: Quote the `$path` variable
If the path contains spaces, the path following the space will be lost unless we quote the variable. TODO: Get the `cd` command working with spaces
-rwxr-xr-xqcd9
1 files changed, 5 insertions, 4 deletions
diff --git a/qcd b/qcd
index 25ce7e1..8f97611 100755
--- a/qcd
+++ b/qcd
@@ -41,7 +41,8 @@ function add_shortcut () {
# Don't add the shortcut if it already exists
if ! shortcut_exists $shortcut; then
- echo "${shortcut} $(absolute_path ${path})" >> $QCD_DATABASE_FILE
+ path=$(absolute_path "$path")
+ echo "${shortcut} ${path}" >> $QCD_DATABASE_FILE
fi
}
@@ -50,7 +51,7 @@ function change_shortcut () {
local path=$2
if shortcut_exists $shortcut; then
- path=$(absolute_path $path)
+ path=$(absolute_path "$path")
sed -i.bak -E "s/^${shortcut} .+$/${shortcut} ${path//\//\/}/" $QCD_DATABASE_FILE
fi
}
@@ -88,10 +89,10 @@ function qcd () {
case $command in
-a)
- add_shortcut $shortcut $path
+ add_shortcut $shortcut "$path"
;;
-c)
- change_shortcut $shortcut $path
+ change_shortcut $shortcut "$path"
;;
-r)
remove_shortcut $shortcut