On 12/16/21 15:52, Jacob Bachmeyer wrote:
If they can have a location fixed relative to the script, the Perl core module 
FindBin and pragmatic module lib can help here:

Or if using bash or similar you take do something like this,
which is a simplified version of the Kawa start-up script:

#!/bin/bash
thisfile=`command -v $0`
case "$thisfile" in
  "") echo "installation error - can't find path to $0"; exit -1 ;;
  /*) ;;
  *) thisfile="$PWD/$thisfile"  ;;
esac
while test -L "$thisfile"; do thisfile=$(readlink -f "$thisfile"); done
kawadir=`dirname "$thisfile" | sed -e 's|/bin\(/\.\)*$||'`
CLASSPATH="$kawadir/lib/kawa.jar:${CLASSPATH}"
export CLASSPATH
exec ${JAVA-java} -Dkawa.home="${kawadir}" kawa.repl "$@"

The idea is you can have:

ANYDIR/bin/kawa
ANYDIR/lib/kawa.jar
ANYDIR/share/kawa/...

Then if you execute ANYDIR/bin/kawa directly, or via a symlink,
or if ANYDIR/bin (or a symlink) is on your PATH the script will set
$kawadir to ANYDIR. Given that it can find ANYDIR/lib/kawa.jar,
ANYDIR/share/kawa or other needed files.
--
        --Per Bothner
p...@bothner.com   http://per.bothner.com/

Reply via email to