Skip to content

Commit a1a2344

Browse files
committed
Merge pull request #2948 from practicalswift/lint-python-lint-script
[gardening] Prevent globbing and word splitting. Handle case where "cd" fails.
2 parents 2b5beb9 + 7ca0e2b commit a1a2344

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

utils/python-lint

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#!/bin/bash
22

3-
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
3+
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
44

55
python -c 'import flake8; import flake8_import_order' 2>/dev/null
6-
if [[ $? -ne 0 ]]; then
6+
if [[ $? != 0 ]]; then
77
echo "Missing modules flake8 or flake8-import-order. Please be sure to install these python packages before linting."
88
exit 1
99
fi
1010

11-
cd $SCRIPT_DIR/..
11+
cd "$SCRIPT_DIR/.."
12+
if [[ $? != 0 ]]; then
13+
echo "Could not change directory to '$SCRIPT_DIR/..'."
14+
exit 1
15+
fi
1216
flake8

0 commit comments

Comments
 (0)