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

Re: Can $_ substitute $0 when nofunctionargzero



On Jun 9,  7:06pm, Sebastian Gniazdowski wrote:
} Subject: 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."

That should probably say "the environment of every external command"
because the second part does not apply to builtins and subshells.

} 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?

I had a bit of trouble untangling your "unless" clause there but if I
understand you correctly then I don't think you've overlooked any
other problems.

On Jun 9,  8:33pm, Sebastian Gniazdowski wrote:
} Subject: Re: Can $_ substitute $0 when nofunctionargzero
}
} I read through discussion on ZSH_SCRIPT and ZSH_ARGZERO. Could there
} be one more parameter added?

At the risk of becoming one of PWS's second category of outraged frothy
gibberers, there are already several other ways to obtain this:

    $(print -P %N), which works for any zsh of the past 16 years
    ${(%):-%N}, which has worked for the past 13 years
    ${funcstack[1]} (or $funcstack[0] if ksharrays), somewhat newer

(Not all versions that have $funcstack also treat "source" as a stack
position, as I recall, though $funcstack has been around a long time.)

If the concern (see discussion of add-zsh-hook-widget) is that plugins
need to work arcoss a range of versions, then adding another builtin
parameter is not going to be very useful.



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