The use of "declare -A flaghash" (associative array) was introduced
in PR #205, which works perfectly for Bash 4.x, but OS X insists on
shipping a very outdated Bash 3.2.x.
This patch hides the "bash: declare: -A: invalid option" error message
and allows the bash completion script to continue gracefully on
OS X, albeit without the benefit of the new feature in PR #205.
Fixes#240
Since the switch from *bytes.Buffer to io.Writer, errors can no longer
be ignored. Also makes the reuse of GenBashCompletion in
GenBashCompletionFile without a buffer treat errors properly again.
In Pull Request #178, the use of `builtin compopt` as a test condition
is inappropriate. Use `[[ $(type -t compopt) = "builtin" ]]` instead.
Also clean up formatting of the resulting bash completion script.
This slightly changes IsAvailableCommand in that a non-runnable command
with a runnable subcommand is now 'Available'
We also use IsAvailableCommand in the rest of the codebase instead of
half kinda sorta doing it incorrectly other places.
This first `cd` to a specified directory, then
lists the subdirectories therein with `_filedir -d`.
This can be used by e.g. `hugo --theme=[Tab][Tab]`, which would
give a list of subdirectories under the `themes` directory.
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 https://github.com/spf13/cobra/pull/103