zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Can this snippet be further improved?
Date: Fri, 28 Jul 2023 22:09:17 -0500	[thread overview]
Message-ID: <CAKc7PVD7Ha9QoQzd2nmLBMiOwQhe5STqX17a98py2neFJPdJ+Q@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7bvvZ4CPYqumCg5qbFXSRa+svnsAn2rJtZqw7jvZCMOcA@mail.gmail.com>

On Fri, 28 Jul 2023 at 16:38, Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Fri, Jul 28, 2023 at 3:07 AM Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
> > >     0=${${ZERO:-${(%):-%x}}:A}
>
> What is $ZERO ?  (I'm not very familiar with the "zsh plugin standard" here.)

ZERO is a $0-like variable however provided by the plugin manager. If
a plugin supports it then it may be easily loaded in an non-standard
way, like eval "$(<plugin-file.zsh):" (a faster method, however if the
script is compiled, then dot/source wins,so it's controversial…),

> Is there a reason not to use ${funcstack[1]} instead of ${(%):-%x} ?
> I presume you're assigning 0= at top level of the plugin, otherwise %x
> is going to be the file where the function is defined rather than the
> file where the function is being executed and further you'd mess up
> FUNCTIONARGZERO et al.  I suppose %x doesn't require zsh/parameter, is
> that really an issue?

I think that the returning of origin source file is a plus – one can
throw in the 0="…" snippet in any kind of file, hash-bang script,
sourced script and autoload function and always get expected result. I
think that if it'll be called in a function defined inside the sourced
script, then it'll still return the same, correct file path.

> As to :A vs. :P, it almost seems like :a:P would be preferable to
> either of those ... :A is described as ":a followed by realpath()
> except where there is no realpath(3)" whereas :P is "LIKE realpath()"
> but doesn't actually require realpath(3).

Thanks, it seems to clarify the :A and :P difference, I'll go for :P then.

-- 
Best regards,
Sebastian Gniazdowski


  reply	other threads:[~2023-07-28 22:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28 14:53 Sebastian Gniazdowski
2023-07-28 15:06 ` Sebastian Gniazdowski
2023-07-28 21:37   ` Bart Schaefer
2023-07-29  3:09     ` Sebastian Gniazdowski [this message]
2023-07-28 22:17       ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKc7PVD7Ha9QoQzd2nmLBMiOwQhe5STqX17a98py2neFJPdJ+Q@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).