Menu

#97 MacOS change in shell script

closed
nobody
None
5
2012-04-01
2012-03-25
No

In the Mac OS version of Maxima Maxima.App/Contents/Resources.maxima.sh in principle could be run from a text shell.
In Emacs org mode, maxima is supported, but it expects a command maxima in the path.
Creating a symlink named maxima in /usr/local/bin does not work because maxima.sh uses dirname $0 to set some paths,
and being call though a symlink returns the path of the location where the symlink lives.
Attached is a modified maxima.sh which allows symlinks ti the script which then will work.
Perhaps something like this can be included in the next release.
I am not really a shell script hacker, so I assume there is room for improvement in the script.

Discussion

  • Erich Neuwirth

    Erich Neuwirth - 2012-03-25

    new shell script

     
  • Andrej Vodopivec

    You can also put this line into your .emacs file:

    (setq-default maxima-command "<path to maxima.sh>")

     
  • Erich Neuwirth

    Erich Neuwirth - 2012-03-25

    I fear this will not work. It works for maxima mode in emacse, but it does not work for org-babel mode for maxima. org-babel mode creates the following command line:
    (cmd (format "maxima --very-quiet -r 'batchload(%S)$' %s"
    in-file cmdline)))
    It does not use maxima-command from maxima mode!
    I know this is not very good style.
    But having a wring maxima command on the path would be helpful anyhow.

     
  • Andrej Vodopivec

    Can you check if this works for you:

    ------------------------- maxima.sh ------------------------
    #!/bin/bash

    SCRIPT="${BASH_SOURCE[0]}"
    while [ -L "$SCRIPT" ] ; do SCRIPT=`(readlink "$SCRIPT")` ; done

    ROOT=`(cd \`dirname "$SCRIPT"\` > /dev/null 2>&1 ; pwd)`
    MAXIMA_PREFIX=$ROOT/maxima/
    export MAXIMA_PREFIX

    PATH="$MAXIMA_PREFIX/bin:$PATH"
    export PATH

    exec "$MAXIMA_PREFIX/bin/maxima" "$1" "$2" "$3" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
    ------------------------- maxima.sh ------------------------

     
  • Erich Neuwirth

    Erich Neuwirth - 2012-03-31

    The script works on my machine.
    Thank you.

     
  • Andrej Vodopivec

    The changes are now in git.

     
  • Andrej Vodopivec

    • status: open --> closed
     

Log in to post a comment.