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

Re: Can $_ substitute $0 when nofunctionargzero

documentation says: "The  last  argument of the previous command.
Also, this parameter is set in the environment of every command
executed to the full pathname of the command."

Turns out it's the first sentence that happens. Last argument to
`source' is substituted for $_. But in real word, $_ can still be used
when option functionargzero is unset, unless someone will came up with
a standard of how plugins can be parametrized – they're normally
sourced without any additional arguments.

Any more flaws in this?

Best regards,
Sebastian Gniazdowski

On 9 June 2016 at 18:44, Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
> Hello,
> this (one line):
> mkdir -p pathcomponent; echo 'echo "0: $0, _: $_";' >
> pathcomponent/sourceme; setopt nofunctionargzero; source
> pathcomponent/sourceme
> outputs:
> 0: /bin/zsh, _: pathcomponent/sourceme
> So it looks like $_ can take back what nofunctionargzero takes away:
> path to sourced file. Normally $0 is used in many plugins, making them
> incompatible with nofunctionargzero. Z-sy-h has an explicit check for
> this and does:
>   echo "zsh-syntax-highlighting: error: not compatible with
> Can $_ take over? This would mean such scripts can be compatible with
> emulate sh and ksh.
> Best regards,
> Sebastian Gniazdowski

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