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

Re: ksh compatibility: initial value of $_



On Mon, Apr 3, 2023 at 4:17 AM Jun. T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> > 2023/04/01 2:45, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > Similar behavior from ksh, so it really is whatever happens to be in
> > the environment for '_' rather than an actual pathname.
>
> Well, I think this is _the_ behavior ksh document specifies. If what
> we want to achieve is just the ksh compatibility then this is enough?
>
> But of course we can do better. The patch below ignores the $_ in
> environment and tries to guess the executable/script pathname.
>
> Or we can use this only if $_ is not in environment (I guess bash
> behaves this way).

I would choose that last, but I suppose it could also be contingent on
emulation mode.

RE the draft patch:

> +       /* search each dir in PARH */
> +       const char *path, *sep;
> +       char *real;
> +       int pathlen, dirlen;
> +       path = getenv("PATH");

I take it this is happening early enough that zsh's internal setting
of the path is not yet done.

After consideration I don't think any of my other specific comments
would be helpful, so I'll just make the general observation that when
I brought up the topic I didn't think it would require this much
effort!




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