From: Felipe Contreras <felipe.contreras@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: What's the equivalent of ${BASH_SOURCE[0]}?
Date: Sat, 16 Mar 2024 03:33:25 -0600 [thread overview]
Message-ID: <CAMP44s0L6h56QG-P3AyULu-NVk8OpJbOCKefYwKYR_KdywjNmg@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZSfgKN19A8rY1DGnz+Aj_iOERvNaLX=Liye0Co9O-tvg@mail.gmail.com>
On Fri, Mar 15, 2024 at 11:07 PM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> On Fri, Mar 15, 2024 at 9:28 AM Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
> >
> > I meant the name of the source script file
>
> Like $ZSH_SCRIPT ?
No. Le'ts get the terminology straight from zsh manpages:
In describing $0 it says:
If the FUNCTION_ARGZERO option is set, $0 is set ... upon entry to a
sourced script to the name of the script
So when you do "source ./lib.sh" inside that script "./lib.sh" is the
name of the sourced script.
On the other hand this is the description of $ZSH_SCRIPT:
If zsh was invoked to run a script, this is the name of the script
So if "lib.sh" is sourced from "foo.sh", then $ZSH_SCRIPT would be
"foo.sh", whereas ${BASH_SOURCE[0]} would be "./lib.sh".
Both are "names of a script", but one is an "invoked script" and the
other is a "sourced script". Correct?
I'm looking for the name of the *sourced* script. So it would be
something like $ZSH_SOURCE (if it existed).
--
Felipe Contreras
next prev parent reply other threads:[~2024-03-16 9:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 21:56 What's the opposite of ZSH_ARGZERO? Felipe Contreras
2024-03-07 5:16 ` Bart Schaefer
2024-03-15 16:28 ` What's the equivalent of ${BASH_SOURCE[0]}? Felipe Contreras
2024-03-16 5:07 ` Bart Schaefer
2024-03-16 9:33 ` Felipe Contreras [this message]
2024-03-17 21:36 ` Bart Schaefer
2024-03-16 9:43 ` Roman Perepelitsa
2024-03-16 11:59 ` Felipe Contreras
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=CAMP44s0L6h56QG-P3AyULu-NVk8OpJbOCKefYwKYR_KdywjNmg@mail.gmail.com \
--to=felipe.contreras@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@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).