Merge branch 'typesettounset' into declarednull

Adds 'setopt typeset_to_unset', documentation, failure tests for POSIX incompatibilies, etc.
declarednull
Bart Schaefer 3 years ago
commit f85cb45045

@ -165,6 +165,7 @@ _comp_options=(
NO_posixidentifiers
NO_shwordsplit
NO_shglob
NO_typesettounset
NO_warnnestedvar
NO_warncreateglobal
)

@ -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

@ -1942,6 +1942,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)

@ -2491,7 +2491,7 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
return NULL;
}
}
if (isset(POSIXBUILTINS))
if (isset(TYPESETTOUNSET))
pm->node.flags |= PM_DEFAULTED;
} else {
if (idigit(*pname))

@ -259,6 +259,7 @@ static struct optname optns[] = {
{{NULL, "transientrprompt", 0}, TRANSIENTRPROMPT},
{{NULL, "trapsasync", 0}, TRAPSASYNC},
{{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},

@ -2538,6 +2538,7 @@ enum {
TRANSIENTRPROMPT,
TRAPSASYNC,
TYPESETSILENT,
TYPESETTOUNSET,
UNSET,
VERBOSE,
VIMODE,

@ -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)), see workers/47748.

@ -4,7 +4,7 @@
#
%prep
setopt POSIX_BUILTINS
setopt POSIX_BUILTINS TYPESET_TO_UNSET
%test
@ -117,3 +117,47 @@
}
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:All identifiers are variable references in POSIX arithmetic
F:POSIX has neither math functions nor floating point
>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>

Loading…
Cancel
Save