about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2016-02-07 21:01:08 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2016-02-07 21:01:08 +0000
commit1ab316c9b8bcf60db091ed0cabe3930a52a0d965 (patch)
tree45fadd1f94d5e78cbc0db6a3dd02a0144214c445
parentdd2aa858073e57a52c541cce04fb99ba7553c6b8 (diff)
downloadzsh-1ab316c9b8bcf60db091ed0cabe3930a52a0d965.tar.gz
zsh-1ab316c9b8bcf60db091ed0cabe3930a52a0d965.tar.xz
zsh-1ab316c9b8bcf60db091ed0cabe3930a52a0d965.zip
37895: $ZSH_SCRIPT is POSIX $0 but always availble
-rw-r--r--Doc/Zsh/params.yo7
-rw-r--r--Src/params.c1
2 files changed, 8 insertions, 0 deletions
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 672209267..ae859ce6c 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -951,6 +951,13 @@ 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)).
diff --git a/Src/params.c b/Src/params.c
index 76ed61c39..0233e2b00 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -813,6 +813,7 @@ 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_VERSION", ztrdup_metafy(ZSH_VERSION));
     setsparam("ZSH_PATCHLEVEL", ztrdup_metafy(ZSH_PATCHLEVEL));
     setaparam("signals", sigptr = zalloc((SIGCOUNT+4) * sizeof(char *)));