Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shellcheck SC2124 in the generated script #34

Merged
merged 3 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/completely/templates/template.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion spec/approvals/cli/generated-script
Original file line number Diff line number Diff line change
Expand Up @@ -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'*)
Expand Down
3 changes: 2 additions & 1 deletion spec/approvals/cli/generated-script-alt
Original file line number Diff line number Diff line change
Expand Up @@ -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'*)
Expand Down
3 changes: 2 additions & 1 deletion spec/approvals/cli/generated-wrapped-script
Original file line number Diff line number Diff line change
Expand Up @@ -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\'*)'
Expand Down
3 changes: 2 additions & 1 deletion spec/approvals/cli/test/completely-tester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'*)
Expand Down
3 changes: 2 additions & 1 deletion spec/approvals/completions/function
Original file line number Diff line number Diff line change
Expand Up @@ -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\'*)'
Expand Down
3 changes: 2 additions & 1 deletion spec/approvals/completions/script
Original file line number Diff line number Diff line change
Expand Up @@ -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'*)
Expand Down
3 changes: 2 additions & 1 deletion spec/approvals/completions/script-only-spaces
Original file line number Diff line number Diff line change
Expand Up @@ -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'*)
Expand Down
3 changes: 2 additions & 1 deletion spec/approvals/completions/script-with-debug
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions spec/completely/commands/generate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/completely/tester_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion spec/fixtures/tester/default.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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'*)
Expand Down