Skip to content

Commit

Permalink
fix string regex comparison bashism
Browse files Browse the repository at this point in the history
  • Loading branch information
florianjacob committed Nov 18, 2016
1 parent e3baeb9 commit be20ad1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions snazzer
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ glob2grep_file() {
FILE=$1
OUT=$(mktemp)

# check if every line starts with either / or *, if not it's a syntax error.
# check if every line starts with either / or *, if not, quit with a syntax error.
while read -r line; do
if ! [[ "$line" =~ ^[/\*].* ]]; then
echo "SYNTAX ERROR: $1 contains lines that start with neither / nor *." >&2
if ! echo "$line" | grep '^[/*]' >/dev/null; then
echo "SYNTAX ERROR: $1 contains line $line that start with neither / nor *." >&2
exit 12
fi
done < "$1"
Expand Down
6 changes: 3 additions & 3 deletions snazzer-measure
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ glob2grep_file() {
FILE=$1
OUT=$(mktemp)

# check if every line starts with either / or *, if not it's a syntax error.
# check if every line starts with either / or *, if not, quit with a syntax error.
while read -r line; do
if ! [[ "$line" =~ ^[/\*].* ]]; then
echo "SYNTAX ERROR: $1 contains lines that start with neither / nor *." >&2
if ! echo "$line" | grep '^[/*]' >/dev/null; then
echo "SYNTAX ERROR: $1 contains line $line that start with neither / nor *." >&2
exit 12
fi
done < "$1"
Expand Down

0 comments on commit be20ad1

Please sign in to comment.