mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
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:
parent
2a426b5c59
commit
97f831a4fd
1 changed files with 7 additions and 4 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue