@@ -98,7 +98,7 @@ rm -rf ${DOCS_FOLDER}/*
9898[tasks .check-npx ]
9999description = " Check npx is installed"
100100script = '''
101- if ! which npx >/dev/null; then
101+ if ! command -v npx >/dev/null 2>&1 ; then
102102 echo "❌ npx could not be found"
103103 echo " Consider installing npx with: npm install -g npx"
104104 exit 1
108108[tasks .check-awk ]
109109description = " Check awk is installed"
110110script = '''
111- if ! which awk >/dev/null; then
111+ if ! command -v awk >/dev/null 2>&1 ; then
112112 echo "❌ awk could not be found"
113113 echo " Consider installing awk (usually pre-installed on Unix systems)"
114114 exit 1
118118[tasks .check-perl ]
119119description = " Check perl is installed"
120120script = '''
121- if ! which perl >/dev/null; then
121+ if ! command -v perl >/dev/null 2>&1 ; then
122122 echo "❌ perl could not be found"
123123 echo " Consider installing perl (usually pre-installed on Unix systems)"
124124 exit 1
128128[tasks .check-jq ]
129129description = " Check jq is installed (version 1.7 or higher, but below 2.0)"
130130script = '''
131- if ! which jq >/dev/null; then
131+ if ! command -v jq >/dev/null 2>&1 ; then
132132 echo "❌ jq could not be found"
133133 echo " Consider installing jq: brew install jq (macOS) or apt-get install jq (Linux)"
134134 exit 1
135135fi
136136
137- jq_version=$(jq --version 2>&1 | grep -oE '[0-9]+\.[0-9]+' | head -1)
138- jq_major=$(echo "$jq_version" | cut -d. -f1)
139- jq_minor=$(echo "$jq_version" | cut -d. -f2)
137+ jq_version=$(jq --version 2>/dev/null | sed -E 's/^jq-([0-9]+)\.([0-9]+).*/\1.\2/')
138+ if ! printf '%s' "$jq_version" | grep -Eq '^[0-9]+\.[0-9]+$'; then
139+ echo "❌ Could not determine jq version (got: '$jq_version')"
140+ exit 1
141+ fi
142+ jq_major=${jq_version%%.*}
143+ jq_minor=${jq_version#*.}
140144
141145if [ "$jq_major" -lt 1 ] || ([ "$jq_major" -eq 1 ] && [ "$jq_minor" -lt 7 ]); then
142146 echo "❌ jq version $jq_version is too old (require >= 1.7)"
143147 exit 1
144148fi
145149
146150if [ "$jq_major" -ge 2 ]; then
147- echo "⚠️ Warning: jq version $jq_version is untested (expected 1.7-1.x )"
151+ echo "⚠️ Warning: jq version $jq_version is untested (expected >= 1.7 and < 2.0 )"
148152fi
149153'''
150154
0 commit comments