Skip to content

Instantly share code, notes, and snippets.

@marks
Last active May 21, 2018 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marks/0dcd77a5ef6bf0ecd7b431193ac04b00 to your computer and use it in GitHub Desktop.
Save marks/0dcd77a5ef6bf0ecd7b431193ac04b00 to your computer and use it in GitHub Desktop.
octave
#!/bin/sh -e
if command -v matlab >/dev/null 2>&1; then
if [ $# -gt 1 ]; then
# Remove ".m" script suffix if it exists, see http://www.mathworks.com/help/matlab/ref/matlablinux.html
COMMAND="${2%.m}"
matlab -nodisplay -nosplash -nodesktop -r "run $COMMAND; quit;"
else
echo "Error: Expecting argument 2 to contain the command to run in Matlab"
exit 1
fi
else
octave "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment