I am trying to create a symbolic-link by using:
$ ln -s path/to/foo.sh ~/.local/bin/bar
In the path where foo.sh is executed there is another file, named foo
.
The following bash-script executes successfully when launched directly from the terminal (i.e. $ ./foo.sh), however, when I use the symbolic-link bar
, it throws an error:
# foo.sh
1 #!/usr/bin/env bash
2 appname=`basename $0 | sed s,\.sh$,,`
3
4 dirname=`dirname $0`
5 tmp="${dirname#?}"
6
7 if [ "${dirname%$tmp}" != "/" ]; then
8 dirname=$PWD/$dirname
9 fi
10 LD_LIBRARY_PATH=$dirname
11 export LD_LIBRARY_PATH
12 $dirname/$appname $*
I don't understand why i get the following error, when I try to launch, script above from the symbolic link bar
:
bash: warning: shell level (1000) too high, resetting to 1
$dirname/$appname $*
./bar again. (if you name the link bar.sh it will exec bar), the script by it self doesnt make sense... maybe if you describe what you intend to do there may be a better solution