help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: $0 (or argv[0]) not used in error messages in zsh -c inlinescripts
Date: Tue, 20 Sep 2022 16:35:36 -0700	[thread overview]
Message-ID: <CAH+w=7Z+GWfkZTqwCG4L4kNU8SEpzeSWAh3PFXO2n==SBXBUnQ@mail.gmail.com> (raw)
In-Reply-To: <20220920131851.3rc27t4cfhwxchay@chazelas.org>

I believe that comes down to this bit of code in zwarning() (utils.c):

    char *prefix = scriptname ? scriptname : (argzero ? argzero : "");
         * scriptname is set when sourcing scripts, so that we get the
         * correct name instead of the generic name of whatever
         * program/script is running.  It's also set in shell functions,
         * so test locallevel, too.
        nicezputs((isset(SHINSTDIN) && !locallevel) ? "zsh" : prefix, stderr);

In parseopts() (init.c) for the -c option there is:

                if (toplevel)
                    scriptname = scriptfilename = ztrdup("zsh");

So because scriptname is always preferred and at toplevel is always
set, you get the observed behavior.

This is all pretty tangled up with POSIX_ARGZERO as well, so I'm not
certain of the correct fix.

      reply	other threads:[~2022-09-20 23:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20 13:18 Stephane Chazelas
2022-09-20 23:35 ` Bart Schaefer [this message]

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:

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

  git send-email \
    --in-reply-to='CAH+w=7Z+GWfkZTqwCG4L4kNU8SEpzeSWAh3PFXO2n==SBXBUnQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \


* 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


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).