summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@ipost.com>2021-04-12 13:59:06 -0700
committerBart Schaefer <schaefer@ipost.com>2021-04-12 13:59:06 -0700
commitb3613e4895f7b059558c4ef211189b516dbf903d (patch)
tree5ac6989a564cfb079b73a1f13a3d2a89ff881bb9
parentAdd TYPESET_DOES_NOT_SET option (cf. 48469) (diff)
downloadzsh-b3613e4895f7b059558c4ef211189b516dbf903d.tar
zsh-b3613e4895f7b059558c4ef211189b516dbf903d.tar.gz
zsh-b3613e4895f7b059558c4ef211189b516dbf903d.tar.bz2
zsh-b3613e4895f7b059558c4ef211189b516dbf903d.tar.lz
zsh-b3613e4895f7b059558c4ef211189b516dbf903d.tar.xz
zsh-b3613e4895f7b059558c4ef211189b516dbf903d.tar.zst
zsh-b3613e4895f7b059558c4ef211189b516dbf903d.zip
Change TYPESET_DOES_NOT_SET to TYPESET_TO_UNSET to avoid double-negative
-rw-r--r--Doc/Zsh/builtins.yo6
-rw-r--r--Doc/Zsh/options.yo10
-rw-r--r--Src/builtin.c2
-rw-r--r--Src/options.c2
-rw-r--r--Src/zsh.h2
-rw-r--r--Test/D06subscript.ztst5
-rw-r--r--Test/E03posix.ztst45
7 files changed, 67 insertions, 5 deletions
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index a7afe42cf..61dc6986f 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1872,7 +1872,11 @@ ifnzman(noderef(Local Parameters))\
retain their special attributes when made local.
For each var(name)tt(=)var(value) assignment, the parameter
-var(name) is set to var(value).
+var(name) is set to var(value). If the assignment is omitted and var(name)
+does em(not) refer to an existing parameter, a new parameter is intialized
+to empty string, zero, or empty array (as appropriate), em(unless) the
+shell option tt(TYPESET_TO_UNSET) is set. When that option is set,
+the parameter attributes are recorded but the parameter remains unset.
If the shell option tt(TYPESET_SILENT) is not set, for each remaining
var(name) that refers to a parameter that is already set, the name and
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index b3bf11f5c..6a1f82b07 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1926,6 +1926,16 @@ If the option is set, they will only be shown when parameters are selected
with the `tt(-m)' option. The option `tt(-p)' is available whether or not
the option is set.
)
+pindex(TYPESET_TO_UNSET)
+pindex(NO_TYPESET_TO_UNSET)
+pindex(TYPESETTOUNSET)
+pindex(NOTYPESETTOUNSET)
+item(tt(TYPESET_TO_UNSET) <K> <S>)(
+When declaring a new parameter with any of the `tt(typeset)' family of
+related commands, the parameter remains unset unless and until a
+value is explicity assigned to it, either in the `tt(typeset)' command
+itself or as a later assignment statement.
+)
pindex(VERBOSE)
pindex(NO_VERBOSE)
pindex(NOVERBOSE)
diff --git a/Src/builtin.c b/Src/builtin.c
index edd4cad44..6d119f7a5 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2491,7 +2491,7 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
return NULL;
}
}
- if (isset(TYPESETDOESNOTSET))
+ if (isset(TYPESETTOUNSET))
pm->node.flags |= PM_DEFAULTED;
} else {
if (idigit(*pname))
diff --git a/Src/options.c b/Src/options.c
index 766ffdfdb..23935ae18 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -257,8 +257,8 @@ static struct optname optns[] = {
{{NULL, "sunkeyboardhack", 0}, SUNKEYBOARDHACK},
{{NULL, "transientrprompt", 0}, TRANSIENTRPROMPT},
{{NULL, "trapsasync", 0}, TRAPSASYNC},
-{{NULL, "typesetdoesnotset", OPT_EMULATE|OPT_BOURNE}, TYPESETDOESNOTSET},
{{NULL, "typesetsilent", OPT_EMULATE|OPT_BOURNE}, TYPESETSILENT},
+{{NULL, "typesettounset", OPT_EMULATE|OPT_BOURNE}, TYPESETTOUNSET},
{{NULL, "unset", OPT_EMULATE|OPT_BSHELL}, UNSET},
{{NULL, "verbose", 0}, VERBOSE},
{{NULL, "vi", 0}, VIMODE},
diff --git a/Src/zsh.h b/Src/zsh.h
index 12efb784f..490407ad0 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2536,8 +2536,8 @@ enum {
SUNKEYBOARDHACK,
TRANSIENTRPROMPT,
TRAPSASYNC,
- TYPESETDOESNOTSET,
TYPESETSILENT,
+ TYPESETTOUNSET,
UNSET,
VERBOSE,
VIMODE,
diff --git a/Test/D06subscript.ztst b/Test/D06subscript.ztst
index c1a8d79cf..4225c543c 100644
--- a/Test/D06subscript.ztst
+++ b/Test/D06subscript.ztst
@@ -289,3 +289,8 @@ F:Regression test for workers/42297
>14 24
>b b
>b?rbaz foob?r
+
+ i=1,3
+ [[ ${a[$i]} = ${a[i]} ]]
+0f:Math evaluation of commas in array subscripts
+F:In math, (($i)) should be the same as ((i)).
diff --git a/Test/E03posix.ztst b/Test/E03posix.ztst
index a2769f3aa..fb394986d 100644
--- a/Test/E03posix.ztst
+++ b/Test/E03posix.ztst
@@ -4,7 +4,7 @@
#
%prep
- setopt POSIX_BUILTINS TYPESET_DOES_NOT_SET
+ setopt POSIX_BUILTINS TYPESET_TO_UNSET
%test
@@ -117,3 +117,46 @@
}
0:readonly with typeset -p
>typeset -g -r var
+
+# Tests expected to fail
+
+ echo -
+0f:A single "-" for echo does not end the arguments
+F:POSIX requires a solitary "-" to be a plain argument
+>-
+
+ ARGV0=sh $ZTST_testdir/../Src/zsh -c 'foreach() { true; }'
+-f:"foreach" is not a reserved word
+
+ ARGV0=sh $ZTST_testdir/../Src/zsh -c 'end() { true; }
+-f:"end" is not a reserved word
+
+ a='a:b:' ARGV0=sh $ZTST_testdir/../Src/zsh -c 'IFS=:; printf "<%s>\n" $a'
+0f:IFS is a separator, not a delimiter
+><a>
+><b>
+
+ a=$'\ra\r\rb' ARGV0=sh $ZTST_testdir/../Src/zsh -c 'IFS=:; printf "<%s>\n" $a'
+0f:All whitespace characters are "IFS whitespace"
+F:isspace('\r') is true so \r should behave like space, \t, \n
+F:This may also need to apply to multibyte whitespace
+><a>
+><b>
+
+ ARGV0=sh $ZTST_testdir/../Src/zsh -c 'IFS=2; printf "<%s>\n" $((11*11))'
+0f:IFS applies to math results (numbers treated as strings)
+><1>
+><1>
+
+ ARGV0=sh $ZTST_testdir/../Src/zsh -c 'inf=42; echo $((inf))'
+0f:The math constant Inf is case-sensitive, with capital I
+>42
+
+ ARGV0=sh $ZTST_testdir/../Src/zsh -c 'EUID=10; echo "$EUID"'
+-f:EUID is not a special variable
+>10
+
+ ARGV0=sh $ZTST_testdir/../Src/zsh -c "printf '<%10s>\n' St$'\M-C\M-)'phane"
+0f:Width of %s is computed in bytes not characters
+F:This is considered a bugfix in zsh
+>< Stéphane>