zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Following up from before 5.0.5:  Change initialization of parameters
Date: Sun, 02 Feb 2014 12:48:48 -0800	[thread overview]
Message-ID: <140202124848.ZM13805@torch.brasslantern.com> (raw)

Some weeks ago, before the several rounds of finding critcal bugs shortly
after each release and therefore making PWS repeat himself, there was a
discussion about the handling of various parameters that are "special" to
zsh but not to a POSIX shell.

Here's a first pass at initializing several of these parameters as unset
(rather than e.g. set to empty string).  There are probably others that
could get similar treatment.  I fiddled with a few more that overlap with
various emulation modes but found problems; e.g. having OPTND/OPTARG unset
actually breaks the getopts command: that's probably a bug.

Possibly the most interesting one here is $_ which changes from READONLY
to DONTIMPORT.  This is what started the previous thread: $_ is said to
be commonly used as a throwaway in some scripting idioms.  The only
reason I can see why it was ever read-only is because it's going to be
overwritten at regular intervals, so one cannot rely on it keeping any
value one might assign to it.


diff --git a/Src/params.c b/Src/params.c
index dc41c6c..59d503c 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -263,7 +263,7 @@ static initparam special_params[] ={
 #define NULL_GSU BR((GsuScalar)(void *)NULL)
 #define IPDEF1(A,B,C) {{NULL,A,PM_INTEGER|PM_SPECIAL|C},BR(NULL),GSU(B),10,0,NULL,NULL,NULL,0}
 IPDEF1("#", pound_gsu, PM_READONLY),
-IPDEF1("ERRNO", errno_gsu, 0),
+IPDEF1("ERRNO", errno_gsu, PM_UNSET),
 IPDEF1("GID", gid_gsu, PM_DONTIMPORT | PM_RESTRICTED),
 IPDEF1("EGID", egid_gsu, PM_DONTIMPORT | PM_RESTRICTED),
 IPDEF1("HISTSIZE", histsize_gsu, PM_RESTRICTED),
@@ -279,11 +279,11 @@ IPDEF2("USERNAME", username_gsu, PM_DONTIMPORT|PM_RESTRICTED),
 IPDEF2("-", dash_gsu, PM_READONLY),
 IPDEF2("histchars", histchars_gsu, PM_DONTIMPORT),
 IPDEF2("HOME", home_gsu, PM_UNSET),
-IPDEF2("TERM", term_gsu, 0),
+IPDEF2("TERM", term_gsu, PM_UNSET),
 IPDEF2("TERMINFO", terminfo_gsu, PM_UNSET),
 IPDEF2("WORDCHARS", wordchars_gsu, 0),
 IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT),
-IPDEF2("_", underscore_gsu, PM_READONLY),
+IPDEF2("_", underscore_gsu, PM_DONTIMPORT),
 IPDEF2("KEYBOARD_HACK", keyboard_hack_gsu, PM_DONTIMPORT),
 
 #ifdef USE_LOCALE
@@ -326,16 +326,17 @@ IPDEF5("SHLVL", &shlvl, varinteger_gsu),
 IPDEF5("TRY_BLOCK_ERROR", &try_errflag, varinteger_gsu),
 
 #define IPDEF7(A,B) {{NULL,A,PM_SCALAR|PM_SPECIAL},BR((void *)B),GSU(varscalar_gsu),0,0,NULL,NULL,NULL,0}
+#define IPDEF7U(A,B) {{NULL,A,PM_SCALAR|PM_SPECIAL|PM_UNSET},BR((void *)B),GSU(varscalar_gsu),0,0,NULL,NULL,NULL,0}
 IPDEF7("OPTARG", &zoptarg),
 IPDEF7("NULLCMD", &nullcmd),
-IPDEF7("POSTEDIT", &postedit),
+IPDEF7U("POSTEDIT", &postedit),
 IPDEF7("READNULLCMD", &readnullcmd),
 IPDEF7("PS1", &prompt),
-IPDEF7("RPS1", &rprompt),
-IPDEF7("RPROMPT", &rprompt),
+IPDEF7U("RPS1", &rprompt),
+IPDEF7U("RPROMPT", &rprompt),
 IPDEF7("PS2", &prompt2),
-IPDEF7("RPS2", &rprompt2),
-IPDEF7("RPROMPT2", &rprompt2),
+IPDEF7U("RPS2", &rprompt2),
+IPDEF7U("RPROMPT2", &rprompt2),
 IPDEF7("PS3", &prompt3),
 IPDEF7("PS4", &prompt4),
 IPDEF7("SPROMPT", &sprompt),


                 reply	other threads:[~2014-02-02 20:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=140202124848.ZM13805@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@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).