zsh-workers
 help / color / mirror / code / Atom feed
* Following up from before 5.0.5:  Change initialization of parameters
@ 2014-02-02 20:48 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2014-02-02 20:48 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-02-02 20:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-02 20:48 Following up from before 5.0.5: Change initialization of parameters Bart Schaefer

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