From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id cd5a4d8d for ; Thu, 20 Jun 2019 18:48:13 +0000 (UTC) Received: (qmail 12048 invoked by alias); 20 Jun 2019 18:48:03 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44441 Received: (qmail 8655 invoked by uid 1010); 20 Jun 2019 18:48:03 -0000 X-Qmail-Scanner-Diagnostics: from kahlil.inlv.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25482. spamassassin: 3.4.2. Clear:RC:0(37.59.109.123):SA:0(-1.9/5.0):. Processed in 1.576567 secs); 20 Jun 2019 18:48:03 -0000 X-Envelope-From: martijn@inlv.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at inlv.org does not designate permitted sender hosts) Subject: [PATCH] posix_builtins: allow exporting a readonly To: zsh-workers@zsh.org References: <1c9aa8c0-c8ee-564f-d351-461d4183d533@inlv.org> From: Martijn Dekker Message-ID: Date: Thu, 20 Jun 2019 19:47:23 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <1c9aa8c0-c8ee-564f-d351-461d4183d533@inlv.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit 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