diff --git a/lib/completely/templates/template.erb b/lib/completely/templates/template.erb index d93b29d..1c134c5 100644 --- a/lib/completely/templates/template.erb +++ b/lib/completely/templates/template.erb @@ -6,7 +6,8 @@ <%= function_name %>() { local cur=${COMP_WORDS[COMP_CWORD]} - local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}" + local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compline="${compwords[*]}" % if ENV['COMPLETELY_DEBUG'] if [[ -n "$COMPLETELY_DEBUG" ]]; then diff --git a/spec/approvals/cli/generated-script b/spec/approvals/cli/generated-script index 2b281c1..6a96aa4 100644 --- a/spec/approvals/cli/generated-script +++ b/spec/approvals/cli/generated-script @@ -6,7 +6,8 @@ _mygit_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}" + local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compline="${compwords[*]}" case "$compline" in 'status'*) diff --git a/spec/approvals/cli/generated-script-alt b/spec/approvals/cli/generated-script-alt index c801c71..5836055 100644 --- a/spec/approvals/cli/generated-script-alt +++ b/spec/approvals/cli/generated-script-alt @@ -6,7 +6,8 @@ _mycomps() { local cur=${COMP_WORDS[COMP_CWORD]} - local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}" + local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compline="${compwords[*]}" case "$compline" in 'status'*) diff --git a/spec/approvals/cli/generated-wrapped-script b/spec/approvals/cli/generated-wrapped-script index 9e0206b..f9a72fd 100644 --- a/spec/approvals/cli/generated-wrapped-script +++ b/spec/approvals/cli/generated-wrapped-script @@ -7,7 +7,8 @@ give_comps() { echo $'' echo $'_mygit_completions() {' echo $' local cur=${COMP_WORDS[COMP_CWORD]}' - echo $' local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}"' + echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")' + echo $' local compline="${compwords[*]}"' echo $'' echo $' case "$compline" in' echo $' \'status\'*)' diff --git a/spec/approvals/cli/test/completely-tester.sh b/spec/approvals/cli/test/completely-tester.sh index 8208730..1281700 100644 --- a/spec/approvals/cli/test/completely-tester.sh +++ b/spec/approvals/cli/test/completely-tester.sh @@ -14,7 +14,8 @@ fi _mygit_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}" + local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compline="${compwords[*]}" case "$compline" in 'status'*) diff --git a/spec/approvals/completions/function b/spec/approvals/completions/function index fd104a3..08230d9 100644 --- a/spec/approvals/completions/function +++ b/spec/approvals/completions/function @@ -7,7 +7,8 @@ send_completions() { echo $'' echo $'_completely_completions() {' echo $' local cur=${COMP_WORDS[COMP_CWORD]}' - echo $' local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}"' + echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")' + echo $' local compline="${compwords[*]}"' echo $'' echo $' case "$compline" in' echo $' \'generate\'*)' diff --git a/spec/approvals/completions/script b/spec/approvals/completions/script index df8761a..7714257 100644 --- a/spec/approvals/completions/script +++ b/spec/approvals/completions/script @@ -6,7 +6,8 @@ _completely_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}" + local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compline="${compwords[*]}" case "$compline" in 'generate'*) diff --git a/spec/approvals/completions/script-only-spaces b/spec/approvals/completions/script-only-spaces index ec5bc59..90a94f9 100644 --- a/spec/approvals/completions/script-only-spaces +++ b/spec/approvals/completions/script-only-spaces @@ -6,7 +6,8 @@ _completely_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}" + local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compline="${compwords[*]}" case "$compline" in 'generate'*) diff --git a/spec/approvals/completions/script-with-debug b/spec/approvals/completions/script-with-debug index 017f691..99149f3 100644 --- a/spec/approvals/completions/script-with-debug +++ b/spec/approvals/completions/script-with-debug @@ -6,7 +6,8 @@ _completely_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}" + local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compline="${compwords[*]}" if [[ -n "$COMPLETELY_DEBUG" ]]; then echo "compline: '$compline'" > 'completely-debug.txt' diff --git a/spec/completely/commands/generate_spec.rb b/spec/completely/commands/generate_spec.rb index e60c86c..61d68fe 100644 --- a/spec/completely/commands/generate_spec.rb +++ b/spec/completely/commands/generate_spec.rb @@ -16,6 +16,11 @@ expect { subject.run %w[generate] }.to output_approval('cli/generate/no-args') expect(File.read "completely.bash").to match_approval('cli/generated-script') end + + it "generates a shellcheck compliant script" do + expect { subject.run %w[generate] }.to output_approval('cli/generate/no-args') + expect(`shellcheck completely.bash 2>&1`).to be_empty + end end context "with CONFIG_PATH" do diff --git a/spec/completely/tester_spec.rb b/spec/completely/tester_spec.rb index d29074d..b10d81f 100644 --- a/spec/completely/tester_spec.rb +++ b/spec/completely/tester_spec.rb @@ -24,7 +24,7 @@ end end - describe '#test', :focus do + describe '#test' do it "returns an array with completions" do expect(subject.test compline).to eq ["command", "conquer"] end diff --git a/spec/fixtures/tester/default.bash b/spec/fixtures/tester/default.bash index 8c91d19..b212310 100644 --- a/spec/fixtures/tester/default.bash +++ b/spec/fixtures/tester/default.bash @@ -6,7 +6,8 @@ _cli_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}" + local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compline="${compwords[*]}" case "$compline" in 'command childcommand'*)