--- imach/distributions/osx/imach	2018/04/21 21:11:45	1.1
+++ imach/distributions/osx/imach	2018/04/21 21:13:27	1.2
@@ -1,8 +1,19 @@
 #!/bin/bash
+# Borrowed to gnuplot
+# record prior dir
+STARTDIR=`pwd`
 
-read -d '' EXECUTE <<DACODE
-cd $(dirname "$0")/../Resources/bin
-pwd
-./imach
-DACODE
-osascript -e "tell application \"Terminal\" to do script \"$EXECUTE\""
+# get the full path to the bundle's MacOS directory
+# and define BINDIR
+CWD=$(cd "$(dirname "$0")"; pwd)
+TOP="`dirname \"$CWD\"`/Resources"
+BINDIR="${TOP}/bin"
+
+# Strip out the argument added by the OS, if any
+if /bin/expr "x$1" : '^x-psn_' > /dev/null; then
+    shift 1
+fi
+
+cd "$STARTDIR"
+
+open -a Terminal "$BINDIR"/imach "$@"