Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ksh compatibility: initial value of $_



On Mon, Apr 3, 2023 at 5:14 AM Jun. T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> 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.

It wouldn't be portable across shells, though, and ...

> 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.

... we already have $ZSH_SCRIPT for that if portability is not an issue.

> 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.

This is my feeling as well.




Messages sorted by: Reverse Date, Date, Thread, Author