Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] posix_builtins: allow exporting a readonly
- X-seq: zsh-workers 44441
- From: Martijn Dekker <martijn@xxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] posix_builtins: allow exporting a readonly
- Date: Thu, 20 Jun 2019 19:47:23 +0100
- In-reply-to: <1c9aa8c0-c8ee-564f-d351-461d4183d533@inlv.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1c9aa8c0-c8ee-564f-d351-461d4183d533@inlv.org>
Op 18-04-18 om 20:58 schreef Martijn Dekker:
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.
This seems to have been forgotten about, so I'm trying again.
To recap:
$ zsh -c 'readonly foo=123; export foo' # OK
$ zsh --emulate sh -c 'readonly foo=123; export foo' # BUG
zsh:1: read-only variable: foo
I had another look at it and I think this patch (attached) should be
even more straightforward. It simply checks if we are running the
'export' command and then reverts to normal behaviour instead of the
special-casing for POSIXBUILTINS which is incorrect for this case.
Note that the patched code block is only executed with POSIXBUILTINS
active so won't otherwise affect anything in any case.
Also, attempts to assign using 'export' still correctly error out with
the patch, as they do on other shells:
$ zsh --emulate sh -c 'readonly foo=123; export foo=123'
zsh:1: read-only variable: foo
Thanks,
- M.
--
modernish -- harness the shell
https://github.com/modernish/modernish
Messages sorted by:
Reverse Date,
Date,
Thread,
Author