-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add euox pipefail check for bash scripts (#266)
* Add euox pipefail check * Make the script panic in case of errors * Fix linter issues Signed-off-by: Andrew Nikitin <[email protected]>
- Loading branch information
Showing
5 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Ensures that all bash scripts in the repository use `set -euox pipefail` or `set -euo pipefail` statement at the beginning. | ||
|
||
set -euo pipefail | ||
|
||
INVALID_FILES_FOUND=0 | ||
|
||
for BASH_SCRIPT in $(find . -type f -name "*.sh") | ||
do | ||
if ( ! grep -q "set -euo pipefail" "${BASH_SCRIPT}" ) && ( ! grep -q "set -euox pipefail" "${BASH_SCRIPT}" ) | ||
then | ||
echo "${BASH_SCRIPT}" | ||
INVALID_FILES_FOUND=1 | ||
fi | ||
done | ||
|
||
if [[ INVALID_FILES_FOUND -eq 1 ]] | ||
then | ||
echo "" | ||
echo "The bash scripts above must include either 'set -euo pipefail' or 'set -euox pipefail." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/bash | ||
|
||
set -euox pipefail | ||
|
||
if [ -n "$1" ]; then | ||
PKG_NAME=$1 | ||
else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/bash | ||
|
||
set -euox pipefail | ||
|
||
if [ -n "$1" ]; then | ||
PKG_NAME=$1 | ||
else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters