zsh-workers
 help / color / mirror / code / Atom feed
From: Martijn Dekker <martijn@inlv.org>
To: zsh-workers@zsh.org
Subject: [PATCH] posix_builtins: allow exporting a readonly
Date: Thu, 20 Jun 2019 19:47:23 +0100	[thread overview]
Message-ID: <af2935f6-32c7-8594-8fed-8744e6f6844a@inlv.org> (raw)
In-Reply-To: <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

  parent reply	other threads:[~2019-06-20 18:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-18 19:58 [PATCH] posix_builtins: allow exporting a reaonly Martijn Dekker
2018-04-18 20:07 ` Bart Schaefer
2018-04-21 12:57   ` Martijn Dekker
2019-06-20 18:47 ` Martijn Dekker [this message]
2019-06-21  8:59   ` [PATCH] posix_builtins: allow exporting a readonly Peter Stephenson
2019-06-22 11:54     ` Martijn Dekker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af2935f6-32c7-8594-8fed-8744e6f6844a@inlv.org \
    --to=martijn@inlv.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).