1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-22 16:20:23 +02:00

48560: add TYPESET_TO_UNSET option to remove initialization of parameters

Changes typeset such that ${newparam-notset} yields "notset" and
"typeset -p newparam" does not show an assignment to the parameter.  This
is similar to the default behavior of bash and ksh, with minor differences
in typeset output.

Also add tests for some POSIX incompatibilities plus minor changes for test
harness robustness.
This commit is contained in:
Bart Schaefer 2021-04-18 13:58:09 -07:00
parent 56ccb4a975
commit 82ff9f24f1
15 changed files with 102 additions and 18 deletions

View file

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

View file

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

View file

@ -393,6 +393,11 @@ is compared to the pattern, and the first matching key found is the
result. On failure substitutes the length of the array plus one, as
discussed under the description of `tt(r)', or the empty string for an
associative array.
Note: Although `tt(i)' may be applied to a scalar substitution to find
the offset of a substring, the results are likely to be misleading when
searching within substitutions that yield an empty string, or when
searching for the empty substring.
)
item(tt(I))(
Like `tt(i)', but gives the index of the last match, or all possible