bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Directory names hard-coded in Texinfo Perl scripts


From: Per Bothner
Subject: Re: Directory names hard-coded in Texinfo Perl scripts
Date: Thu, 16 Dec 2021 16:21:09 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0

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
per@bothner.com   http://per.bothner.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]