Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- ### Author: Orestis Ousoultzoglou
- # <xlxs4@protonmail.ch>
- #
- ### Assert we are at the root repo dir.
- # -> $0 expands to the name of the script,
- # because bash gets invoked with
- # a file of commands.
- # -> % is the pattern-matching operator.
- # It removes shortest matched substring
- # from the rear (in this case, everything
- # after the last '/' in the current path).
- # -> Example: if $0 is /home/foo/bar.sh,
- # cd ${0%/*} expands to cd /home/foo
- cd ${0%/*}
- ### Grab MATLAB metadata.
- # We launch MATLAB with a variety of
- # startup flags to make things
- # faster and use the CLI mode.
- # -> path is a MATLAB function which
- # returns everything inside the MATLAB path.
- # MATLAB also greets the user with a message
- # when launched without a display.
- # From that message we grab the
- # release and version.
- # Because every default path dir/file sits
- # at /usr/local/, we can safely assume that
- # things added by the user sit elsewhere.
- MHOLD="$(matlab -nosplash -nodisplay -nodesktop -nojvm -noFigureWindows -singleCompThread -r "path;exit" | grep R2 | grep -o '^[^)]\+' | sed 's/(//' | sed -n '/\usr\/local/!p')"
- MRELEASE="$(echo $MHOLD | awk '{print $1}')"
- MVERSION="$(echo $MHOLD | awk '{print $2}')"
- MUPATH="$(echo $MHOLD | sed -re 's,\s+, ,g' | cut -d ' ' -f 3-)"
- ### Display MATLAB release.
- echo -e "\u001b[33;1mMATLAB\u001b[0m \u001b[34;1mrelease:\u001b[0m\u001b[33;1m $MRELEASE\u001b[0m"
- ### Display MATLAB version.
- echo -e "\u001b[33;1mMATLAB\u001b[0m \u001b[34;1mversion:\u001b[0m\u001b[33;1m $MVERSION\u001b[0m"
- ### Display permanent user additions to MATLAB's path.
- echo -e "\u001b[33;1mUser additions to MATLAB \u001b[0m\u001b[33;1mpath\u001b[0m\u001b[34;1m (permanent): $MUPATH\u001b[0m"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement