From c3b0c491ec79dacb7d2f9daa20413b3d8240fa84 Mon Sep 17 00:00:00 2001 From: Lazarus Lazaridis Date: Tue, 6 Mar 2018 23:39:07 +0200 Subject: [PATCH] Handle directories with spaces. Refs #8. --- goto.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/goto.bash b/goto.bash index 7829c28..583661a 100644 --- a/goto.bash +++ b/goto.bash @@ -83,7 +83,7 @@ USAGE # Helpful for ~, ., .. paths function _goto_expand_directory() { - printf "$(cd $1 2>/dev/null && pwd)" + printf "$(cd "$1" 2>/dev/null && pwd)" } # Lists regstered aliases. @@ -116,9 +116,9 @@ function _goto_register_alias() return fi - local directory="$(_goto_expand_directory $2)" + local directory="$(_goto_expand_directory "$2")" if [ -z "$directory" ]; then - _goto_error "failed to register $1 to $2 - can't cd to directory" + _goto_error "failed to register '$1' to '$2' - can't cd to directory" return fi