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

Re: $0 (or argv[0]) not used in error messages in zsh -c inlinescripts



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.




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