Re: How do I determine the home directory of a shell script from ?within the script



On Nov 15, 4:31 pm, ddun...@xxxxxxxx (Darren Dunham) wrote:


That's because you have all absolute components in your path, or you are
providing an absolute filename for execution. Neither of those have to
be true.

$ PATH=.:$PATH
$ cd /tmp
$ foo.sh
./foo.sh
$ ./foo.sh
./foo.sh

That's true (though people with relative pathnames in their PATH
deserve to be melted down). You need to check for a relative $0 and
merge it with the current dir in that case.
.