Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. ### Author: Orestis Ousoultzoglou
  4. # <xlxs4@protonmail.ch>
  5. #
  6.  
  7. ### Assert we are at the root repo dir.
  8. # -> $0 expands to the name of the script,
  9. # because bash gets invoked with
  10. # a file of commands.
  11. # -> % is the pattern-matching operator.
  12. # It removes shortest matched substring
  13. # from the rear (in this case, everything
  14. # after the last '/' in the current path).
  15. # -> Example: if $0 is /home/foo/bar.sh,
  16. # cd ${0%/*} expands to cd /home/foo
  17. cd ${0%/*}
  18.  
  19. ### Grab MATLAB metadata.
  20. # We launch MATLAB with a variety of
  21. # startup flags to make things
  22. # faster and use the CLI mode.
  23. # -> path is a MATLAB function which
  24. # returns everything inside the MATLAB path.
  25. # MATLAB also greets the user with a message
  26. # when launched without a display.
  27. # From that message we grab the
  28. # release and version.
  29. # Because every default path dir/file sits
  30. # at /usr/local/, we can safely assume that
  31. # things added by the user sit elsewhere.
  32. MHOLD="$(matlab -nosplash -nodisplay -nodesktop -nojvm -noFigureWindows -singleCompThread -r "path;exit" | grep R2 | grep -o '^[^)]\+' | sed 's/(//' | sed -n '/\usr\/local/!p')"
  33. MRELEASE="$(echo $MHOLD | awk '{print $1}')"
  34. MVERSION="$(echo $MHOLD | awk '{print $2}')"
  35. MUPATH="$(echo $MHOLD | sed -re 's,\s+, ,g' | cut -d ' ' -f 3-)"
  36.  
  37. ### Display MATLAB release.
  38. echo -e "\u001b[33;1mMATLAB\u001b[0m \u001b[34;1mrelease:\u001b[0m\u001b[33;1m $MRELEASE\u001b[0m"
  39. ### Display MATLAB version.
  40. echo -e "\u001b[33;1mMATLAB\u001b[0m \u001b[34;1mversion:\u001b[0m\u001b[33;1m $MVERSION\u001b[0m"
  41. ### Display permanent user additions to MATLAB's path.
  42. 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