Skip to content

Commit

Permalink
Merge pull request #16 from rsteube/bash-fix-parameter-expansion
Browse files Browse the repository at this point in the history
bash: fix parameter expansion
  • Loading branch information
rsteube authored Apr 3, 2020
2 parents 25348f4 + 05d1b53 commit dbd5912
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions bash/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _%v_callback() {
local last="${COMP_WORDS[${COMP_CWORD}]}"
if [[ $last =~ ^[\"\'] ]] && ! echo "$last" | xargs echo 2>/dev/null >/dev/null ; then
compline="${compline}${last:0:1}"
last="${last/ /\\\\ }"
last="${last// /\\\\ }"
fi
echo "$compline" | sed -e 's/ $/ _/' -e 's/"/\"/g' | xargs %v _carapace bash "$1"
Expand All @@ -28,9 +28,9 @@ _%v_completions() {
if [[ $last =~ ^[\"\'] ]] && ! echo "$last" | xargs echo 2>/dev/null >/dev/null ; then
compline="${compline}${last:0:1}"
last="${last/ /\\\\ }"
last="${last// /\\\\ }"
else
last="${last/ /\\\ }"
last="${last// /\\\ }"
fi
local state=$(echo "$compline" | sed -e "s/ \$/ _/" -e 's/"/\"/g' | xargs %v _carapace bash state)
Expand All @@ -41,7 +41,7 @@ _%v_completions() {
%v
esac
[[ $last =~ ^[\"\'] ]] && COMPREPLY=("${COMPREPLY[@]/\\ /\ }")
[[ $last =~ ^[\"\'] ]] && COMPREPLY=("${COMPREPLY[@]//\\ /\ }")
[[ $COMPREPLY == */ ]] && compopt -o nospace
}
Expand Down
8 changes: 4 additions & 4 deletions example/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _example_callback() {
local last="${COMP_WORDS[${COMP_CWORD}]}"
if [[ $last =~ ^[\"\'] ]] && ! echo "$last" | xargs echo 2>/dev/null >/dev/null ; then
compline="${compline}${last:0:1}"
last="${last/ /\\\\ }"
last="${last// /\\\\ }"
fi
echo "$compline" | sed -e 's/ $/ _/' -e 's/"/\"/g' | xargs example _carapace bash "$1"
Expand All @@ -26,9 +26,9 @@ _example_completions() {
if [[ $last =~ ^[\"\'] ]] && ! echo "$last" | xargs echo 2>/dev/null >/dev/null ; then
compline="${compline}${last:0:1}"
last="${last/ /\\\\ }"
last="${last// /\\\\ }"
else
last="${last/ /\\\ }"
last="${last// /\\\ }"
fi
local state=$(echo "$compline" | sed -e "s/ \$/ _/" -e 's/"/\"/g' | xargs example _carapace bash state)
Expand Down Expand Up @@ -162,7 +162,7 @@ _example_completions() {
esac
[[ $last =~ ^[\"\'] ]] && COMPREPLY=("${COMPREPLY[@]/\\ /\ }")
[[ $last =~ ^[\"\'] ]] && COMPREPLY=("${COMPREPLY[@]//\\ /\ }")
[[ $COMPREPLY == */ ]] && compopt -o nospace
}
Expand Down

0 comments on commit dbd5912

Please sign in to comment.