From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28667 invoked by alias); 2 Feb 2014 20:49:03 -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: 32337 Received: (qmail 3812 invoked from network); 2 Feb 2014 20:48:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140202124848.ZM13805@torch.brasslantern.com> Date: Sun, 02 Feb 2014 12:48:48 -0800 X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Following up from before 5.0.5: Change initialization of parameters MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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),