From c9cffd46c25fffb26b24a172631ab29901be0f95 Mon Sep 17 00:00:00 2001 From: magras Date: Sun, 26 Jul 2020 14:11:28 +0300 Subject: [PATCH 1/3] Added a few more missing quotes to prevent argument splitting --- up.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/up.sh b/up.sh index f6a0b85..733ab86 100755 --- a/up.sh +++ b/up.sh @@ -41,7 +41,7 @@ __upnum() { } _up() { - local p="$(dirname $PWD)" + local p="$(dirname "$PWD")" local w="${COMP_WORDS[COMP_CWORD]}" COMPREPLY=( $(IFS=';' compgen -S/ -W "${p//\//;}" -- "$w") ) @@ -71,8 +71,8 @@ up() { fi # fallback - if [[ $1 == - || -d $1 ]]; then - cd $1 + if [[ "$1" == - || -d "$1" ]]; then + cd "$1" return fi From 96f2b47bd85d4a24a6277033c1a28e5bfa3a8d50 Mon Sep 17 00:00:00 2001 From: magras Date: Sun, 26 Jul 2020 15:08:32 +0300 Subject: [PATCH 2/3] Simplify compgen call --- up.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/up.sh b/up.sh index 733ab86..91aa3cb 100755 --- a/up.sh +++ b/up.sh @@ -44,7 +44,7 @@ _up() { local p="$(dirname "$PWD")" local w="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=( $(IFS=';' compgen -S/ -W "${p//\//;}" -- "$w") ) + COMPREPLY=( $(IFS='/' compgen -S/ -W "$p" -- "$w") ) } up() { From 125bb36587a5ea9ef43aa008ad0d5747ed79e90e Mon Sep 17 00:00:00 2001 From: magras Date: Sun, 26 Jul 2020 15:35:38 +0300 Subject: [PATCH 3/3] Fixed word splitting inside completion list --- up.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/up.sh b/up.sh index 91aa3cb..3148e0a 100755 --- a/up.sh +++ b/up.sh @@ -44,7 +44,8 @@ _up() { local p="$(dirname "$PWD")" local w="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=( $(IFS='/' compgen -S/ -W "$p" -- "$w") ) + COMPREPLY=() + while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(IFS='/' compgen -S/ -W "$p" -- "$w") } up() {