diff options
| author | Teddy Wing | 2016-07-21 23:10:07 -0400 |
|---|---|---|
| committer | Teddy Wing | 2016-07-21 23:11:16 -0400 |
| commit | f0189d6dc374b4238892e3309e116317a6d8c48c (patch) | |
| tree | 00e2bea9d8e3fee3b0014c1525a7de1f5a10b4f9 | |
| parent | 7de785f2f7ad0387f56323f6f14a67357293651f (diff) | |
| download | qcd-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-x | qcd | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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 |
