From ab335e6b7d5fdd9be83cafb7c4068e12ef0c413b Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Thu, 4 Nov 2021 16:06:52 -0700 Subject: [PATCH] Pass shell script arguments without splitting (#4629) Unquoted $@ splits shell script arguments on whitespace. Use the "$@" form to pass arguments exactly as received. --- check/all | 2 +- check/asv_run | 2 +- check/doctest | 2 +- check/format-incremental | 2 +- check/mypy | 4 ++-- check/nbformat | 4 ++-- check/npm | 2 +- check/npx | 2 +- check/pylint | 2 +- check/pytest | 4 ++-- check/ts-build | 2 +- check/ts-coverage | 2 +- check/ts-lint | 2 +- check/ts-lint-and-format | 2 +- check/ts-test | 2 +- check/ts-test-e2e | 2 +- dev_tools/pr_monitor.sh | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/check/all b/check/all index b87cbe58dcd..450aa2624f1 100755 --- a/check/all +++ b/check/all @@ -38,7 +38,7 @@ cd "$(git rev-parse --show-toplevel)" apply_arg="" only_changed=0 rev="" -for arg in $@; do +for arg in "$@"; do if [[ "${arg}" == "--only-changed-files" ]]; then only_changed=1 elif [[ "${arg}" == "--apply-format-changes" ]]; then diff --git a/check/asv_run b/check/asv_run index 6e17239806e..1bfbe218abf 100755 --- a/check/asv_run +++ b/check/asv_run @@ -12,4 +12,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" export ASV_PYTHONPATH="$(git rev-parse --show-toplevel)/examples" -asv run $@ +asv run "$@" diff --git a/check/doctest b/check/doctest index 156a7e83b6d..8340ccd76b5 100755 --- a/check/doctest +++ b/check/doctest @@ -19,4 +19,4 @@ cd "$(git rev-parse --show-toplevel)" source dev_tools/pypath -python dev_tools/docs/run_doctest.py $@ +python dev_tools/docs/run_doctest.py "$@" diff --git a/check/format-incremental b/check/format-incremental index fe96a00ff6d..ea6ddf23315 100755 --- a/check/format-incremental +++ b/check/format-incremental @@ -40,7 +40,7 @@ cd "$(git rev-parse --show-toplevel)" only_print=1 only_changed=1 rev="" -for arg in $@; do +for arg in "$@"; do if [[ "${arg}" == "--apply" ]]; then only_print=0 elif [[ "${arg}" == "--all" ]]; then diff --git a/check/mypy b/check/mypy index b0e1f141beb..d863a66922e 100755 --- a/check/mypy +++ b/check/mypy @@ -12,7 +12,7 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" config_file='mypy.ini' -for arg in $@; do +for arg in "$@"; do if [[ "${arg}" == "--next" ]]; then config_file='mypy-next.ini' shift @@ -22,7 +22,7 @@ done CIRQ_PACKAGES=$(env PYTHONPATH=. python dev_tools/modules.py list --mode package-path) echo -e -n "\033[31m" -mypy --config-file=dev_tools/conf/mypy.ini $@ $CIRQ_PACKAGES dev_tools examples +mypy --config-file=dev_tools/conf/mypy.ini "$@" $CIRQ_PACKAGES dev_tools examples result=$? echo -e -n "\033[0m" diff --git a/check/nbformat b/check/nbformat index 85865384725..5c9893d4f2a 100755 --- a/check/nbformat +++ b/check/nbformat @@ -15,7 +15,7 @@ ################################################################################ only_print=1 -for arg in $@; do +for arg in "$@"; do if [[ "${arg}" == "--apply" ]]; then only_print=0 else @@ -52,4 +52,4 @@ elif (( only_print == 1 )); then exit 1 else echo -e "\033[33mReformatted changed notebooks\033[0m." -fi \ No newline at end of file +fi diff --git a/check/npm b/check/npm index cf2ec980614..0c7fa392c87 100755 --- a/check/npm +++ b/check/npm @@ -26,4 +26,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" -npm --prefix 'cirq-web/cirq_ts' $@ \ No newline at end of file +npm --prefix 'cirq-web/cirq_ts' "$@" diff --git a/check/npx b/check/npx index 08ea59eb9ae..10bbda894fe 100755 --- a/check/npx +++ b/check/npx @@ -26,4 +26,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" cd 'cirq-web/cirq_ts' -npx $@ \ No newline at end of file +npx "$@" diff --git a/check/pylint b/check/pylint index 517c20e1aed..7b6874626e1 100755 --- a/check/pylint +++ b/check/pylint @@ -14,4 +14,4 @@ cd "$(git rev-parse --show-toplevel)" CIRQ_MODULES=$(env PYTHONPATH=. python dev_tools/modules.py list --mode package-path) # Add dev_tools to $PYTHONPATH so that pylint can find custom checkers -env PYTHONPATH=dev_tools pylint --rcfile=dev_tools/conf/.pylintrc $@ $CIRQ_MODULES dev_tools examples +env PYTHONPATH=dev_tools pylint --rcfile=dev_tools/conf/.pylintrc "$@" $CIRQ_MODULES dev_tools examples diff --git a/check/pytest b/check/pytest index 3aa396e2e15..24f792899cf 100755 --- a/check/pytest +++ b/check/pytest @@ -19,7 +19,7 @@ cd "$(git rev-parse --show-toplevel)" PYTEST_ARGS=() ACTUALLY_QUIET="" -for arg in $@; do +for arg in "$@"; do if [[ "${arg}" == "--actually-quiet" ]]; then ACTUALLY_QUIET=1 else @@ -48,4 +48,4 @@ if [ "$RESULT" = 5 ]; then exit 0 fi -exit "$RESULT" \ No newline at end of file +exit "$RESULT" diff --git a/check/ts-build b/check/ts-build index 824c7607b49..554a852dc09 100755 --- a/check/ts-build +++ b/check/ts-build @@ -25,4 +25,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" -check/npx webpack --mode production $@ +check/npx webpack --mode production "$@" diff --git a/check/ts-coverage b/check/ts-coverage index 32c8f548d6a..88c73cee0d1 100755 --- a/check/ts-coverage +++ b/check/ts-coverage @@ -25,4 +25,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" -check/npm run coverage $@ \ No newline at end of file +check/npm run coverage "$@" diff --git a/check/ts-lint b/check/ts-lint index 03918f5bc29..9d1215b3bd8 100755 --- a/check/ts-lint +++ b/check/ts-lint @@ -25,4 +25,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" -check/npm run lint $@ \ No newline at end of file +check/npm run lint "$@" diff --git a/check/ts-lint-and-format b/check/ts-lint-and-format index 23d32ce1c29..f3e19f480e4 100755 --- a/check/ts-lint-and-format +++ b/check/ts-lint-and-format @@ -25,4 +25,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" -check/npm run fix $@ \ No newline at end of file +check/npm run fix "$@" diff --git a/check/ts-test b/check/ts-test index 0ec6c8984a6..bf25831e5b9 100755 --- a/check/ts-test +++ b/check/ts-test @@ -27,4 +27,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" -check/npm run test $@ \ No newline at end of file +check/npm run test "$@" diff --git a/check/ts-test-e2e b/check/ts-test-e2e index dbf09de3dba..9e2ec6b9b88 100755 --- a/check/ts-test-e2e +++ b/check/ts-test-e2e @@ -27,4 +27,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" -check/npm run test-e2e $@ +check/npm run test-e2e "$@" diff --git a/dev_tools/pr_monitor.sh b/dev_tools/pr_monitor.sh index 1acfc04a1c8..f6ee1f8b006 100755 --- a/dev_tools/pr_monitor.sh +++ b/dev_tools/pr_monitor.sh @@ -54,4 +54,4 @@ cd "${repo_dir}" # Do the thing. export PYTHONPATH=${repo_dir} -python3 ${repo_dir}/dev_tools/pr_monitor.py $@ +python3 ${repo_dir}/dev_tools/pr_monitor.py "$@"