From a862c7b17b294f75a83a354ff1dc16975836dc33 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Mon, 18 Mar 2024 15:36:45 -0400 Subject: [PATCH] Use `sed` instead of `awk` to extract Bison version --- src/bison.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/bison.sh b/src/bison.sh index e7060801..0da66e3d 100755 --- a/src/bison.sh +++ b/src/bison.sh @@ -3,23 +3,20 @@ set -e BISONFLAGS=-Wall -readonly BISON_VER=$(bison -V) +readonly BISON_MAJOR=$(bison -V | sed -E 's/^.+ ([0-9]+)\..*$/\1/g;q') +readonly BISON_MINOR=$(bison -V | sed -E 's/^.+ [0-9]+\.([0-9]+)\..*$/\1/g;q') + add_flag () { - if awk <<<"$BISON_VER" -v major="$1" -v minor="$2" ' - /^bison.*[0-9]+(\.[0-9]+)(\.[0-9]+)?$/ { - match($0, /[0-9]+(\.[0-9]+)(\.[0-9]+)?$/); - split(substr($0, RSTART), ver, "."); - if (ver[1] == major && ver[2] >= minor) { exit 0 } else { exit 1 } - }'; then - BISONFLAGS="-D$3 $BISONFLAGS" + if [[ "$BISON_MAJOR" -eq "$1" && "$BISON_MINOR" -ge "$2" ]]; then + BISONFLAGS="$BISONFLAGS -D$3" fi } -add_flag 3 5 api.token.raw=true -add_flag 3 6 parse.error=detailed add_flag 3 0 parse.error=verbose add_flag 3 0 parse.lac=full add_flag 3 0 lr.type=ielr +add_flag 3 5 api.token.raw=true +add_flag 3 6 parse.error=detailed echo "BISONFLAGS=$BISONFLAGS"