Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Can $_ substitute $0 when nofunctionargzero
- X-seq: zsh-users 21638
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Can $_ substitute $0 when nofunctionargzero
- Date: Fri, 10 Jun 2016 08:12:39 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=aLdd5H9xyIv0AgUlI4Pd0JwPYqDcg4z+/pJ0Q5YguLk=; b=qZR/hgp7Z3WjZtuq3QHv2Q/iK6QZ21G1KKSOAvk5BE61qHmKT2NN6vSpgji3//t7aS UXaBfh7Jzcz6AA4HbhDlGEJGlTYD3jzbKyaJroClXfCrvJQa9iiM7BH3nRtBRvdxum0i vqXrSFA1BFuVo5Z8r/PxoyGKeLvHOKJbozQS/nNgigMcoZc88TGZXwwJiHPqXgYDuWK5 WlfFGUHAYl0MQ+YRyO2Q90AidRD8dEmu2hcigxqbS7AT/SJuMMV9blbpAvWwKDMkbbXx osJ1Yjrq6rROg9rhAMzSnU9vQ82h1Y0GuqvpFf8Jhbhxr1b+Y5p6LO1f4y08Fdmgn0uF B73A==
- In-reply-to: <160609134641.ZM4758@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVBXdgRVMUrZwvDK93BHycPYC7zeafg0=TNmqYEA=xdn+g@mail.gmail.com> <CAKc7PVAfFPtpJ0APsN-oE2dpvaijd2_h67acgf9TWvgpfGuJ3Q@mail.gmail.com> <CAKc7PVB4y+dw+0Ox76_YTrzwT1C9sRp2=iX1-JkbPQEUQqe77w@mail.gmail.com> <160609134641.ZM4758@torch.brasslantern.com>
On 9 June 2016 at 22:46, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> That should probably say "the environment of every external command"
> because the second part does not apply to builtins and subshells.
It is little hard to understand. For example something works in following:
local var="I am $_"
> I am local
Wonder if some nice trickery can be done with $_, maybe in patterns
> 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.
I thought about e.g.:
source "/path/plugin" color=red start_in_incremental_search
when sourcing some plugin – that what I meant by "parametrizing".
> 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
That's just great, thanks! I already added "0=${(%):-%N}" to my
plugins. Should have just asked earlier.
> 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.
Yeah I thought about future being sure there's no current remedy for
nofunctionargzero.
Best regards,
Sebastian Gniazdowski
On 9 June 2016 at 22:46, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 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