about summary refs log tree commit diff
path: root/Src/zsh.h
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@ipost.com>2020-11-28 09:23:10 -0800
committerBart Schaefer <schaefer@ipost.com>2021-04-13 21:18:34 -0700
commitdddae7f05582c6c8e91501dbea6106636cd76f6c (patch)
tree7a86eb982ba89eaf5ae323cff206ae84ad279b9e /Src/zsh.h
parent9dc195120cf4e01cd0068f90db12fc9a7eb522b5 (diff)
downloadzsh-dddae7f05582c6c8e91501dbea6106636cd76f6c.tar.gz
zsh-dddae7f05582c6c8e91501dbea6106636cd76f6c.tar.xz
zsh-dddae7f05582c6c8e91501dbea6106636cd76f6c.zip
Add PM_DECLARED and PM_DECLAREDNULL parameter flags.
This addresses the issue that "typeset foo" creates $foo set to an
empty string, which differs from typeset handling in bash and ksh.
It does this by concealing the internal value rather than alter
the way internal values are defaulted.

This imposes the following changes:

A typeset variable with no assignment triggers NO_UNSET warnings
when the name is used in parameter expansion or math.

The typeset -AEFHLRTZailux options are applied upon the first
assignment to the variable.  Explicit unset before the first
assignment discards all of those properties.  If any option is
applied to an existing name, historic behavior is unchanged.

Consequent to the foregoing, the (t) parameter expansion flag
prints nothing until after the first assignment, and the (i)
and (I) subscript flags also print nothing.

The bash behavior of "unset foo; typeset -p foo" is NOT used.
This is called out as an emulation distinction, not a change.

The test cases have not been updated, so several now fail.
The test harness has been updated to declare default values.
Diffstat (limited to 'Src/zsh.h')
-rw-r--r--Src/zsh.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/Src/zsh.h b/Src/zsh.h
index d70a4017c..e98f3e328 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1931,6 +1931,8 @@ struct tieddata {
 #define PM_DONTIMPORT	(1<<22)	/* do not import this variable              */
 #define PM_RESTRICTED	(1<<23) /* cannot be changed in restricted mode     */
 #define PM_UNSET	(1<<24)	/* has null value                           */
+#define PM_DECLARED	(1<<17) /* */
+#define PM_DECLAREDNULL (PM_DECLARED|PM_UNSET)
 #define PM_REMOVABLE	(1<<25)	/* special can be removed from paramtab     */
 #define PM_AUTOLOAD	(1<<26) /* autoloaded from module                   */
 #define PM_NORESTORE	(1<<27)	/* do not restore value of local special    */