Fix b with zsh (again), remove shwordsplit use.
Context: zsh doesn't do string splitting like bash, so it passes the post-processed bazel args to bazel as a single arg. So this CL adds a conditional to split explicitly with zsh using the {=<arg>} flag syntax. Reference: https://zsh.sourceforge.io/FAQ/zshfaq03.html (for shwordsplit) Reference: https://zsh.sourceforge.io/Guide/zshguide05.html (Section 5.4.4) For bash, this uses array[@] to split the list into separate shell words. Test: zsh; source build/envsetup.sh && b test //system/logging/logd:logd-unit-tests --config=linux_x86_64 Test: bash; source build/envsetup.sh && b test //system/logging/logd:logd-unit-tests --config=linux_x86_64 Change-Id: Id92462661bbe1799a6de8dd3393799d91e3044e8
This commit is contained in:
parent
4f9a6abf59
commit
6f4963b99f
1 changed files with 9 additions and 7 deletions
16
envsetup.sh
16
envsetup.sh
|
@ -1858,7 +1858,7 @@ function b()
|
||||||
_trigger_build "all-modules" bp2build $skip_tests USE_BAZEL_ANALYSIS= || return 1
|
_trigger_build "all-modules" bp2build $skip_tests USE_BAZEL_ANALYSIS= || return 1
|
||||||
# Then, run Bazel using the synthetic workspace as the --package_path.
|
# Then, run Bazel using the synthetic workspace as the --package_path.
|
||||||
if [[ -z "$bazel_args" ]]; then
|
if [[ -z "$bazel_args" ]]; then
|
||||||
# If there are no args, show help.
|
# If there are no args, show help and exit.
|
||||||
bazel help
|
bazel help
|
||||||
else
|
else
|
||||||
# Else, always run with the bp2build configuration, which sets Bazel's package path to the synthetic workspace.
|
# Else, always run with the bp2build configuration, which sets Bazel's package path to the synthetic workspace.
|
||||||
|
@ -1882,13 +1882,15 @@ function b()
|
||||||
bazel_args_with_config+=("--config=bp2build ")
|
bazel_args_with_config+=("--config=bp2build ")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$ZSH_VERSION" ]; then
|
|
||||||
# zsh breaks posix by not doing string-splitting on unquoted args
|
|
||||||
# by default. Enable the compatibility option.
|
|
||||||
setopt shwordsplit
|
|
||||||
fi
|
|
||||||
# Call Bazel.
|
# Call Bazel.
|
||||||
bazel ${bazel_args_with_config[@]}
|
if [ -n "$ZSH_VERSION" ]; then
|
||||||
|
# zsh breaks posix by not doing string-splitting on unquoted args
|
||||||
|
# by default. Explicitly use the "=" flag to split.
|
||||||
|
# See https://zsh.sourceforge.io/Guide/zshguide05.html section 5.4.4.
|
||||||
|
bazel ${=bazel_args_with_config}
|
||||||
|
else
|
||||||
|
bazel ${bazel_args_with_config[@]}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue