Change first line of generated bash-completion file

to conform with existing bash-completion snippets and
to suppress Lintian "script-not-executable".
This commit is contained in:
Anthony Fok 2016-01-11 15:37:32 -07:00
parent 2a426b5c59
commit 97f831a4fd

View file

@ -16,9 +16,12 @@ const (
BashCompSubdirsInDir = "cobra_annotation_bash_completion_subdirs_in_dir" BashCompSubdirsInDir = "cobra_annotation_bash_completion_subdirs_in_dir"
) )
func preamble(out io.Writer) error { func preamble(out io.Writer, name string) error {
_, err := fmt.Fprintf(out, `#!/bin/bash _, err := fmt.Fprintf(out, "# bash completion for %-36s -*- shell-script -*-\n", name)
if err != nil {
return err
}
_, err = fmt.Fprintf(out, `
__debug() __debug()
{ {
if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
@ -465,7 +468,7 @@ func gen(cmd *Command, w io.Writer) error {
} }
func (cmd *Command) GenBashCompletion(w io.Writer) error { func (cmd *Command) GenBashCompletion(w io.Writer) error {
if err := preamble(w); err != nil { if err := preamble(w, cmd.Name()); err != nil {
return err return err
} }
if len(cmd.BashCompletionFunction) > 0 { if len(cmd.BashCompletionFunction) > 0 {