Here is a scenario.
/usr/local/bin/collect.sh contains two shell scripts, collect.sh and soxsetup.sh
my home directory ~/bin contains testing versions of collect.sh and soxsetup.sh and point
to different locations
In both cases I want collect.sh to source the soxsetup.sh script that is in the same directory containing collect.sh
Test
So, regular use
I want always use the two scripts from /usr/local/bin
testing use
I want always that the two scripts execute from ~/bin
It does not always work. Different results for different working directories (pwd)
I tested with some bash commands vis...
which,
dirname,
realpath calling bash -x collect.sh from either home ~/bin or /usr/local/bin
In some cases the wrong soxsetup.sh gets invoked. I want to avoid that problem.
If you can help, please test with bash -x from ~ , ~/bin /usr/local/bin
Hints are important.
Herein is my test script
Code:
#!/bin/bash
#
SOXBIN=`dirname $0`
echo "SOXBIN=$SOXBIN"
#
if [ $SOXBIN == '.' ]; then
echo "executing from `pwd`"
SOXBIN=`pwd`
fi
echo "$SOXBIN/soxsetup.sh $1 $2"
. $SOXBIN/soxsetup.sh $1 $2
I tried the above with just
test1
/usr/local/bin/test1
cd /usr/local/bin ; ./test1
cd ~ ; bin/test1
cd ~/bin ; ./test1
I do software work in Baan ERP systems