File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #! /bin/bash
2-
31# This is a shell completion script auto-generated by https://github.com/urfave/cli for bash.
42
53# macOS still ships Bash 3, where bash-completion may not provide
Original file line number Diff line number Diff line change 44 "bytes"
55 "context"
66 "fmt"
7+ "strings"
78 "testing"
89
910 "github.com/stretchr/testify/assert"
@@ -63,6 +64,27 @@ func TestCompletionShell(t *testing.T) {
6364 }
6465}
6566
67+ func TestCompletionBashNoShebang (t * testing.T ) {
68+ // Regression test for https://github.com/urfave/cli/issues/2259
69+ // Bash completion scripts are sourced, not executed, so they must not
70+ // start with a `#!` shebang (flagged by Debian lintian as
71+ // `bash-completion-with-hashbang`).
72+
73+ cmd := & Command {
74+ EnableShellCompletion : true ,
75+ }
76+
77+ r := require .New (t )
78+
79+ bashRender := shellCompletions ["bash" ]
80+ r .NotNil (bashRender , "bash completion renderer should exist" )
81+
82+ output , err := bashRender (cmd , "myapp" )
83+ r .NoError (err )
84+ r .NotEmpty (output , "bash completion output should not be empty" )
85+ r .False (strings .HasPrefix (output , "#!" ), "bash completion should not start with a shebang" )
86+ }
87+
6688func TestCompletionFishFormat (t * testing.T ) {
6789 // Regression test for https://github.com/urfave/cli/issues/2285
6890 // Fish completion was broken due to incorrect format specifiers
You can’t perform that action at this time.
0 commit comments