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

Re: ksh compatibility: initial value of $_



On Tue 4 Apr 2023, at 11:24, Jun. T wrote:
> The following is my revised path.
> # Since $_ is almost always set in environment (though sometimes
> # not useful), this may be going too far (or to excess, don't know
> # the correct words).

I had written a patch very very similar to this in 2018 because of
workers/42193 (as well as users/22875, users/18199, &c.). I wasn't thinking
about $_ at the time; instead, i had created a ZSH_EXECUTABLE_PATH parameter
that resolved the path the first time it was referenced, because i was worried
that it was too niche to waste I/O on it for every invocation of the shell. In
the end i didn't submit the patch because it still felt too elaborate...

Anyway, would it make sense to revive the idea of having a dedicated variable
for it, so you can get the absolute path to the shell regardless of the
environment or what commands might have run before you could capture $_? That
would somewhat address your fear that it's too excessive for how rarely it'd
be used, at least

PS: bash has a similar dedicated parameter, just called BASH... but it doesn't
try to be this accurate about it. If it's a log-in shell, it will use $SHELL,
otherwise it basically does the 'guess the absolute pathname' part of your
getmypath()

dana




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