From 525bec70a24c40d6e1044cbc731609d55b45b6cc Mon Sep 17 00:00:00 2001 From: Sam Darwin Date: Wed, 22 Jan 2025 09:40:13 -0700 Subject: [PATCH] antora_docs: cross-platform compatible scripts (#396) --- libdoc.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdoc.sh b/libdoc.sh index 2507943..0c83cb5 100755 --- a/libdoc.sh +++ b/libdoc.sh @@ -41,7 +41,8 @@ if [ -z "$node_version" ]; then echo "Node.js is not installed" exit 1 fi -major_version=$(echo "$node_version" | egrep -o "v([0-9]+)\." | cut -c 2- | rev | cut -c 2- | rev) +major_version=$(echo "$node_version" | sed -n -E "s/v([0-9]+)\..*$/\1/p") +echo "Node major version is $major_version" if [ "$major_version" -lt "16" ]; then echo "Node.js version $node_version is not supported. Please upgrade to version 16 or higher." node_path=$(which node) @@ -67,7 +68,7 @@ fi if command -v git >/dev/null && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then commit_id=$(git rev-parse HEAD) - commit_id=$(expr substr "$commit_id" 1 7) + commit_id=$(echo "$commit_id" | sed -n -E "s/^(.{7}).*$/\1/p") else commit_id="" fi