Skip to content

Commit

Permalink
make filename extension handling a bash function
Browse files Browse the repository at this point in the history
We were trying to call a bash function with bash stuff like @ () from a
variable.  Stop that.  Just call a function with an arg from a variable
instead of trying to pass around the bash.

Should fix spf13#103
  • Loading branch information
eparis committed May 4, 2015
1 parent 787b737 commit d7c142f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bash_completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ __handle_reply()
fi
}
# The arguments should be in the form "ext1|ext2|extn"
__handle_filename_extension_flag()
{
local ext="$1"
_filedir "@(${ext})"
}
__handle_flag()
{
__debug "${FUNCNAME}: c is $c words[c] is ${words[c]}"
Expand Down Expand Up @@ -213,7 +220,7 @@ func writeFlagHandler(name string, annotations map[string][]string, out *bytes.B
fmt.Fprintf(out, " flags_with_completion+=(%q)\n", name)

ext := strings.Join(value, "|")
ext = "_filedir '@(" + ext + ")'"
ext = "__handle_filename_extension_flag " + ext
fmt.Fprintf(out, " flags_completion+=(%q)\n", ext)
}
}
Expand Down

0 comments on commit d7c142f

Please sign in to comment.