making the bash script swipl_version closer to Isabelle's conventional bash scripts
authorbulwahn
Wed, 02 Feb 2011 13:53:06 +0100
changeset 41690 53b1da988e75
parent 41689 3e39b0e730d6
child 41692 0593a2979cd3
making the bash script swipl_version closer to Isabelle's conventional bash scripts
src/HOL/Tools/Predicate_Compile/etc/settings
src/HOL/Tools/Predicate_Compile/lib/scripts/swipl_version
--- a/src/HOL/Tools/Predicate_Compile/etc/settings	Wed Feb 02 12:34:45 2011 +0100
+++ b/src/HOL/Tools/Predicate_Compile/etc/settings	Wed Feb 02 13:53:06 2011 +0100
@@ -17,4 +17,4 @@
   $(type -p yap) \
   "")"
 
-SWIPL_VERSION=$("$COMPONENT/lib/scripts/swipl_version")
+SWIPL_VERSION="$("$COMPONENT/lib/scripts/swipl_version")"
--- a/src/HOL/Tools/Predicate_Compile/lib/scripts/swipl_version	Wed Feb 02 12:34:45 2011 +0100
+++ b/src/HOL/Tools/Predicate_Compile/lib/scripts/swipl_version	Wed Feb 02 13:53:06 2011 +0100
@@ -7,9 +7,11 @@
 if [ "$EXEC_SWIPL" = "" ]; then
   echo ""
 else
-  # FIXME does not allow spaces in $EXEC_SWIPL
-  # FIXME "expr match" not portable
-  # FIXME prefer $(...) in bash
-  VERSION=`$EXEC_SWIPL --version`
-  echo `expr match "$VERSION" 'SWI-Prolog version \([0-9\.]*\)'`
+  VERSION="$("$EXEC_SWIPL" --version)"
+  REGEXP='^SWI-Prolog version ([0-9\.]*) for .*$'
+  if [[ "$VERSION" =~ $REGEXP ]]; then
+    echo "${BASH_REMATCH[1]}"
+  else
+    echo undefined
+  fi
 fi