2 ms·
> if you run "foo", then $0 is an absolute path to the script. That doesn't seem to be the case. $ cat foo echo $0 $ ./foo ./foo $ export
by akkartik 3y ago
> if you run "foo", then $0 is an absolute path to the script.
That doesn't seem to be the case.
$ cat foo
echo $0
$ ./foo
./foo
$ export PATH=.:$PATH
$ foo
foo
I'm usually on zsh, but I get the same result even varying the shebang inside foo.
- saurik 3y agoOk, I see the case: it is if you actually literally have "." on your PATH. I never ever do this--and consider it super super dangerous--and so it never occurred to me to test that case. So like, if I have "~/bin" on my path, it is converted to an absolute path, but if I have "." on my path and I am in that folder it gives me just foo. Thanks for helping me understand that case...