aboutsummaryrefslogtreecommitdiff
path: root/Bin
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2010-08-04 16:49:47 +0200
committerIan Hinder <ian.hinder@aei.mpg.de>2010-08-04 16:49:47 +0200
commit62b0a3821fd3f9e860bc3306b43e447e427089ac (patch)
tree4b78b5d23555aa20eff2052f7a4e649e7e1475ca /Bin
parent3d6cc02c4fc79e7969adeeeaf3a2a044462e440c (diff)
kranc: Update the Kranc/Bin/kranc script and move some functionality into a new RunKranc.m file
The kranc script now looks for a Kranc installation relative to the path of the kranc script. It also has a "-v" option now to increase verbosity. Exceptions should be printed nicely.
Diffstat (limited to 'Bin')
-rwxr-xr-xBin/kranc52
1 files changed, 29 insertions, 23 deletions
diff --git a/Bin/kranc b/Bin/kranc
index 9e39af0..9f16432 100755
--- a/Bin/kranc
+++ b/Bin/kranc
@@ -1,32 +1,38 @@
#!/bin/bash
-# A shell script to run Kranc on a mathematica input file
-
-INFILE=$1
-
-if ! which math >/dev/null
+# Assume that this script is called from the Kranc/Bin directory
+export KRANCDIR=$(dirname $0)/..
+export KRANCVERBOSE=no
+
+while getopts "v" flag
+do
+ case $flag in
+ "v")
+ export KRANCVERBOSE=yes
+ ;;
+ esac
+done
+
+shift $(expr $OPTIND - 1)
+
+if [ $# -eq 0 ]
then
- echo "Cannot find math executable. Is Mathematica on your path?"
+ echo "Usage: $0 [-v] <script>"
+ exit 1
fi
-LOCALKRANCPATH="Kranc/Tools/CodeGen:Kranc/Tools/MathematicaMisc:Kranc/Tools/External"
+MMASCRIPT=$1
+shift
-if [ -z "$MATHPATH" ]
-then
- MATHPATH=$LOCALKRANCPATH
+MATH_MACOS=/Applications/Mathematica.app/Contents/MacOS/MathKernel
+
+if which math >/dev/null; then
+ MATH=math
+elif [ -x $MATH_MACOS ]; then
+ MATH=$MATH_MACOS
else
- MATHPATH=$LOCALKRANCPATH:$MATHPATH
+ echo "Cannot find math executable. Is Mathematica on your path?"
+ exit 1
fi
-export MATHPATH
-
-math <<EOF
-
-Module[{mp, newPath},
- mp = StringToStream[Environment["MATHPATH"]];
- newPath = Map[ToString, ReadList[mp, Word, WordSeparators->{":"}]];
- \$Path = Join[newPath, \$Path]];
-Needs["Errors\`"];
-exception = Catch[Get["$INFILE"], KrancError];
-PrintError[exception];
-EOF
+$MATH -run "Get[\"$KRANCDIR/Tools/MathematicaMisc/RunKranc.m\"]" $MMASCRIPT </dev/null