Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] posix_builtins: allow exporting a reaonly



POSIX_BUILTINS incorrectly prohibits exporting a readonly variable. All other POSIX shells allow this and there is nothing in the POSIX text[*] that says it's not allowed. The attached patch fixes this.

Thanks,

- M.

[*] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_22
diff --git a/Src/builtin.c b/Src/builtin.c
index 73cfe7a..a75c4b2 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2169,7 +2169,7 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
 	    !ASG_VALUEP(asg))
 	    on |= PM_UNSET;
 	else if (usepm && (pm->node.flags & PM_READONLY) &&
-		 !(on & PM_READONLY)) {
+		 !(on & PM_READONLY) && !(on & PM_EXPORTED)) {
 	    zerr("read-only variable: %s", pm->node.nam);
 	    return NULL;
 	}


Messages sorted by: Reverse Date, Date, Thread, Author