From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24936 invoked by alias); 1 Mar 2016 14:39:28 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38057 Received: (qmail 6910 invoked from network); 1 Mar 2016 14:39:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:subject:reply-to:in-reply-to:references:mime-version:content-type; s=smtpapi; bh=Sy3FkEZkL7K4AZZxBdmIYgLLpgM=; b=BXCUTxsubJW62EQItl +9gDZsCHxDD5DbxNa1NL8yqwPoreBU4PdVX29WSUx3F21U6qCoDzyZ3ORcRWOdv5 pB4YkELahZwsaAk/nCPZ31QNygLZv687R672bVgsv3rDqnUDtUb5/RlPJSPzZsPj cNp21Dywfuqfcx3zeizkwbSpo= From: Greg Klanderman To: zsh-workers@zsh.org Subject: Re: ZSH_SCRIPT Reply-To: Greg Klanderman Date: Tue, 01 Mar 2016 09:39:19 -0500 In-Reply-To: <20160301092746.1472ae95@pwslap01u.europe.root.pri> (Peter Stephenson's message of "Tue, 01 Mar 2016 09:27:46 +0000") Message-ID: <87fuwa8dpk.fsf@lwm.klanderman.net> User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) References: <22221.59800.803540.618862@lwm.klanderman.net> <160224143153.ZM28994@torch.brasslantern.com> <20160225093344.0d2499d5@pwslap01u.europe.root.pri> <87r3g08ycp.fsf@lwm.klanderman.net> <160225150425.ZM14095@torch.brasslantern.com> <87lh6384y5.fsf@lwm.klanderman.net> <20160301092746.1472ae95@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SG-EID: i+zOheVB0lMUqP0z3X/8PPLe+C1hDfxH7g5ommK/LCob5reW5M/a89a8qiyHmNhakGiYc5xUIVEs8m D8MmYcunnIXkgijE4+lJS00fULS4t2Hrauq+M4ta3W7Rlv/DcjVGLWegV/As/WIIKyRD/JQlmJh++6 vDuab8bC2ISkvFRbqG/Mr4Y7cKLM2kGNnhrHjaH+ssdhCh9JbeChEq+Y5Lr35gTtKvk/qN05x76wq9 A= >>>>> On March 1, 2016 Peter Stephenson wrote: > I'm happy with ZSH_SCRIPT only being set for the script and something > else like ZSH_ARGZERO indicating the POSIX $0, if that makes sense. Thank you Peter & Bart.. how about this? Should we explicitly document that ZSH_SCRIPT is empty rather than unset when not invoked as a script? thanks, Greg diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index ae859ce..a3ce880 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -933,6 +933,13 @@ tt(zsh/zutil) module. ) enditem() ) +vindex(ZSH_ARGZERO) +item(tt(ZSH_ARGZERO))( +If zsh was invoked to run a script, this is the name of the script. +Otherwise, it is the name used to invoke the current shell. This is +the same as the value of tt($0) when the tt(POSIX_ARGZERO) option is +set, but is always available. +) vindex(ZSH_EXECUTION_STRING) item(tt(ZSH_EXECUTION_STRING))( If the shell was started with the option tt(-c), this contains @@ -951,17 +958,14 @@ track of versions of the shell during development between releases; hence most users should not use it and should instead rely on tt($ZSH_VERSION). ) -vindex(ZSH_SCRIPT) -item(tt(ZSH_SCRIPT))( -If zsh was invoked to run a script, this is the name of the script. -Otherwise, it is the name used to invoke the current shell. This is -the same as the value of tt($0) when the tt(POSIX_ARGZERO) option is -set, but is always available. -) item(tt(zsh_scheduled_events))( See ifzman(the section `The zsh/sched Module' in zmanref(zshmodules))\ ifnzman(noderef(The zsh/sched Module)). ) +vindex(ZSH_SCRIPT) +item(tt(ZSH_SCRIPT))( +If zsh was invoked to run a script, this is the name of the script. +) vindex(ZSH_SUBSHELL ) item(tt(ZSH_SUBSHELL))( Readonly integer. Initially zero, incremented each time the shell forks diff --git a/Src/init.c b/Src/init.c index 4097327..e96ad2c 100644 --- a/Src/init.c +++ b/Src/init.c @@ -1657,6 +1657,7 @@ zsh_main(UNUSED(int argc), char **argv) opts[PRIVILEGED] = (getuid() != geteuid() || getgid() != getegid()); /* sets ZLE, INTERACTIVE, SHINSTDIN and SINGLECOMMAND */ parseargs(argv, &runscript, &cmd); + zsh_script = runscript; SHTTY = -1; init_io(cmd); diff --git a/Src/params.c b/Src/params.c index 8bd8a8e..c6c6d82 100644 --- a/Src/params.c +++ b/Src/params.c @@ -81,7 +81,8 @@ char *argzero, /* $0 */ *rprompt2, /* $RPROMPT2 */ *sprompt, /* $SPROMPT */ *wordchars, /* $WORDCHARS */ - *zsh_name; /* $ZSH_NAME */ + *zsh_name, /* $ZSH_NAME */ + *zsh_script; /* $ZSH_SCRIPT */ /**/ mod_export char *ifs, /* $IFS */ @@ -813,7 +814,8 @@ createparamtable(void) setsparam("TTY", ztrdup_metafy(ttystrname)); setsparam("VENDOR", ztrdup_metafy(VENDOR)); setsparam("ZSH_NAME", ztrdup_metafy(zsh_name)); - setsparam("ZSH_SCRIPT", ztrdup(posixzero)); + setsparam("ZSH_ARGZERO", ztrdup(posixzero)); + setsparam("ZSH_SCRIPT", ztrdup(zsh_script)); setsparam("ZSH_VERSION", ztrdup_metafy(ZSH_VERSION)); setsparam("ZSH_PATCHLEVEL", ztrdup_metafy(ZSH_PATCHLEVEL)); setaparam("signals", sigptr = zalloc((SIGCOUNT+4) * sizeof(char *)));