Remove perl dependency for bash completions
The commands that are substituted here will only consist of ASCII
characters, so we can avoid the dependency on perl(1) and just use
tr(1).
Tested manually:
```
$ ./scripts/generate_bash_completion.sh --bazel=bazel --output=./complete.bash --prepend=./scripts/bazel-complete-template.bash
$ source complete.bash
$ _bazel__options_for build
```
Fixes
Closes
@@ -154,7 +154,8 @@ _bazel__package_path() {
_bazel__options_for() {
local options
if [[ "${BAZEL_COMMAND_LIST}" =~ ^(.* )?$1( .*)?$ ]]; then
- local option_name=$(echo $1 | perl -ne 'print uc' | tr "-" "_")
+ # assumes option names only use ASCII characters
+ local option_name=$(echo $1 | tr a-z A-Z | tr "-" "_")
eval "echo \${BAZEL_COMMAND_${option_name}_FLAGS}" | tr " " "\n"
fi
}
@@ -164,7 +165,8 @@ _bazel__options_for() {
_bazel__expansion_for() {
local options
if [[ "${BAZEL_COMMAND_LIST}" =~ ^(.* )?$1( .*)?$ ]]; then
- local option_name=$(echo $1 | perl -ne 'print uc' | tr "-" "_")
+ # assumes option names only use ASCII characters
+ local option_name=$(echo $1 | tr a-z A-Z | tr "-" "_")
eval "echo \${BAZEL_COMMAND_${option_name}_ARGUMENT}"
fi
}
