diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-03-29 21:34:23 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-03-29 21:35:19 +0300 |
commit | ecd1f8169c69578baac730d535029212b7ba19ef (patch) | |
tree | cf4c74211533bb3dee33022aa15500fa551bd658 | |
parent | add a helpful comment (diff) | |
download | cgitize-ecd1f8169c69578baac730d535029212b7ba19ef.tar.gz cgitize-ecd1f8169c69578baac730d535029212b7ba19ef.zip |
.ci/local: actually fix grep usage?
Diffstat (limited to '')
-rwxr-xr-x | .ci/local/test.sh | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/.ci/local/test.sh b/.ci/local/test.sh index f0500e4..6216c48 100755 --- a/.ci/local/test.sh +++ b/.ci/local/test.sh @@ -130,26 +130,25 @@ cgitize() { python3 -m cgitize.main --config "$cgitize_conf_path" } -check_contains() ( - # No pipefail so that grep doesn't fuck everything up: - # https://mywiki.wooledge.org/BashPitfalls#pipefail - - set -o errexit -o nounset - +check_contains() { if [ "$#" -lt 1 ]; then echo "usage: ${FUNCNAME[0]} TEST_STRING [PATTERN...]" >&2 return 1 fi + local test_string="$1" shift + local pattern for pattern; do - if ! echo "$test_string" | grep --fixed-strings --silent -- "$pattern"; then + # Be careful to _not_ use grep -q, since this fucks stuff up: + # https://mywiki.wooledge.org/BashPitfalls#pipefail. + if ! echo "$test_string" | grep --fixed-strings -- "$pattern" > /dev/null; then echo "${FUNCNAME[0]}: couldn't find the following pattern: $pattern" >&2 return 1 fi done -) +} verify_commits() { # This is fucking stupid, but otherwise stuff like `if verify_commits;` |