Skip to content
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
2 changes: 0 additions & 2 deletions autocomplete/bash_autocomplete
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

# This is a shell completion script auto-generated by https://github.com/urfave/cli for bash.

# Macs have bash3 for which the bash-completion package doesn't include
Expand Down
22 changes: 22 additions & 0 deletions completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -63,6 +64,27 @@ func TestCompletionShell(t *testing.T) {
}
}

func TestCompletionBashNoShebang(t *testing.T) {
// Regression test for https://github.com/urfave/cli/issues/2259
// Bash completion scripts are sourced, not executed, so they must not
// start with a `#!` shebang (flagged by Debian lintian as
// `bash-completion-with-hashbang`).

cmd := &Command{
EnableShellCompletion: true,
}

r := require.New(t)

bashRender := shellCompletions["bash"]
r.NotNil(bashRender, "bash completion renderer should exist")

output, err := bashRender(cmd, "myapp")
r.NoError(err)
r.NotEmpty(output, "bash completion output should not be empty")
r.False(strings.HasPrefix(output, "#!"), "bash completion should not start with a shebang")
}

func TestCompletionFishFormat(t *testing.T) {
// Regression test for https://github.com/urfave/cli/issues/2285
// Fish completion was broken due to incorrect format specifiers
Expand Down