Skip to content

Commit

Permalink
Pass shell script arguments without splitting (#4629)
Browse files Browse the repository at this point in the history
Unquoted $@ splits shell script arguments on whitespace.
Use the "$@" form to pass arguments exactly as received.
  • Loading branch information
pavoljuhas authored Nov 4, 2021
1 parent d1e7228 commit ab335e6
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion check/all
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion check/asv_run
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
2 changes: 1 addition & 1 deletion check/doctest
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
2 changes: 1 addition & 1 deletion check/format-incremental
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions check/mypy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions check/nbformat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
################################################################################

only_print=1
for arg in $@; do
for arg in "$@"; do
if [[ "${arg}" == "--apply" ]]; then
only_print=0
else
Expand Down Expand Up @@ -52,4 +52,4 @@ elif (( only_print == 1 )); then
exit 1
else
echo -e "\033[33mReformatted changed notebooks\033[0m."
fi
fi
2 changes: 1 addition & 1 deletion check/npm
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"

npm --prefix 'cirq-web/cirq_ts' $@
npm --prefix 'cirq-web/cirq_ts' "$@"
2 changes: 1 addition & 1 deletion check/npx
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"

cd 'cirq-web/cirq_ts'
npx $@
npx "$@"
2 changes: 1 addition & 1 deletion check/pylint
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions check/pytest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -48,4 +48,4 @@ if [ "$RESULT" = 5 ]; then
exit 0
fi

exit "$RESULT"
exit "$RESULT"
2 changes: 1 addition & 1 deletion check/ts-build
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
2 changes: 1 addition & 1 deletion check/ts-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"

check/npm run coverage $@
check/npm run coverage "$@"
2 changes: 1 addition & 1 deletion check/ts-lint
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"

check/npm run lint $@
check/npm run lint "$@"
2 changes: 1 addition & 1 deletion check/ts-lint-and-format
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"

check/npm run fix $@
check/npm run fix "$@"
2 changes: 1 addition & 1 deletion check/ts-test
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"

check/npm run test $@
check/npm run test "$@"
2 changes: 1 addition & 1 deletion check/ts-test-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
2 changes: 1 addition & 1 deletion dev_tools/pr_monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"

0 comments on commit ab335e6

Please sign in to comment.