Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ksh compatibility: initial value of $_
> 2023/03/31 17:18, I wrote:
>
> But, suppose we have a ksh script 'foo' in the current directory:
>
> % cat foo
> #!/usr/bin/ksh
> echo $_
> % ./foo
> /home/takimoto/tmp/./foo
> % ksh ./foo
> /usr/bin/ksh
Both ksh and bash behave this way, but I personally feel that
getting the script name /path/to/foo for both cases is more
natural and useful. There may be a situation where a script
wants to know the pathname of itself, but for almost always
it would not be necessary to distinguish the above two cases.
But probably compatibility with other shells would be more
important? Then guessing executable/script name only if
$_ does not exist in environment would be the way to go.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author