From 08374f72691a8518333d27527f0fdcc74125061c Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Sun, 17 Nov 2013 12:31:07 -0600 Subject: [PATCH] Avoid `expr` for faster preprocessing --- libexec/bats-preprocess | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libexec/bats-preprocess b/libexec/bats-preprocess index 3fb039f..d88b2f1 100755 --- a/libexec/bats-preprocess +++ b/libexec/bats-preprocess @@ -31,12 +31,12 @@ encode_name() { tests=() index=0 +pattern='^ *@test *([^ ].*) *\{ *$' while IFS= read -r line; do let index+=1 - quoted_name="$(expr "$line" : ' *@test *\([^ ].*\) *{ *$' || true)" - - if [ -n "$quoted_name" ]; then + if [[ "$line" =~ $pattern ]]; then + quoted_name="${BASH_REMATCH[1]}" name="$(eval echo "$quoted_name")" encoded_name="$(encode_name "$name")" tests["${#tests[@]}"]="$encoded_name"