-#define att_exported 0x001 /* export to environment */
-#define att_readonly 0x002 /* cannot change */
-#define att_invisible 0x004 /* cannot see */
-#define att_array 0x008 /* value is an array */
-#define att_nounset 0x010 /* cannot unset */
-#define att_function 0x020 /* value is a function */
-#define att_integer 0x040 /* internal representation is int */
-#define att_imported 0x080 /* came from environment */
-#define att_local 0x100 /* variable is local to a function */
-#define att_tempvar 0x200 /* variable came from the temp environment */
-#define att_importstr 0x400 /* exportstr points into initial environment */
-#define att_noassign 0x800 /* assignment not allowed */
+/* First, the user-visible attributes */
+#define att_exported 0x0000001 /* export to environment */
+#define att_readonly 0x0000002 /* cannot change */
+#define att_array 0x0000004 /* value is an array */
+#define att_function 0x0000008 /* value is a function */
+#define att_integer 0x0000010 /* internal representation is int */
+#define att_local 0x0000020 /* variable is local to a function */
+#define att_assoc 0x0000040 /* variable is an associative array */
+#define att_trace 0x0000080 /* function is traced with DEBUG trap */
+#define att_uppercase 0x0000100 /* word converted to uppercase on assignment */
+#define att_lowercase 0x0000200 /* word converted to lowercase on assignment */
+#define att_capcase 0x0000400 /* word capitalized on assignment */
+
+#define user_attrs (att_exported|att_readonly|att_integer|att_local|att_trace|att_uppercase|att_lowercase|att_capcase)
+
+#define attmask_user 0x0000fff
+
+/* Internal attributes used for bookkeeping */
+#define att_invisible 0x0001000 /* cannot see */
+#define att_nounset 0x0002000 /* cannot unset */
+#define att_noassign 0x0004000 /* assignment not allowed */
+#define att_imported 0x0008000 /* came from environment */
+#define att_special 0x0010000 /* requires special handling */
+#define att_nofree 0x0020000 /* do not free value on unset */
+
+#define attmask_int 0x00ff000
+
+/* Internal attributes used for variable scoping. */
+#define att_tempvar 0x0100000 /* variable came from the temp environment */
+#define att_propagate 0x0200000 /* propagate to previous scope */
+
+#define attmask_scope 0x0f00000