From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13782 invoked by alias); 21 Apr 2018 12:57:48 -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: 42699 Received: (qmail 28361 invoked by uid 1010); 21 Apr 2018 12:57:48 -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.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(37.59.109.123):SA:0(-1.9/5.0):. Processed in 2.278832 secs); 21 Apr 2018 12:57:48 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: martijn@inlv.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Subject: Re: [PATCH] posix_builtins: allow exporting a reaonly To: Bart Schaefer References: <1c9aa8c0-c8ee-564f-d351-461d4183d533@inlv.org> From: Martijn Dekker Cc: zsh-workers@zsh.org Message-ID: <88bb2098-0b83-a320-d4b9-44ef6143ea13@inlv.org> Date: Sat, 21 Apr 2018 14:57:40 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Op 18-04-18 om 22:07 schreef Bart Schaefer: > On Wed, Apr 18, 2018 at 12:58 PM, Martijn Dekker wrote: >> 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. > > I hope it's really that simple -- see thread about typeset -T and > read-only and resulting confusion, e.g. zsh-workers/42061 and > references. I can't really find anything in that thread or its references that seems relevant. Exporting readonly variables was already possible with POSIXBUILTINS off, so I don't see how it could harm anything to allow it with POSIXBUILTINS on. Here is some more context than was provided by the patch. Note that all of this is only executed if POSIXBUILTINS is on. if (isset(POSIXBUILTINS)) { /* * Stricter rules about retaining readonly attribute in this case. */ if ((on & (PM_READONLY|PM_EXPORTED)) && (!usepm || (pm->node.flags & PM_UNSET)) && !ASG_VALUEP(asg)) on |= PM_UNSET; else if (usepm && (pm->node.flags & PM_READONLY) && !(on & PM_READONLY) && !(on & PM_EXPORTED)) { zerr("read-only variable: %s", pm->node.nam); return NULL; } } As the comment says, that block applies stricter rules about retaining the readonly attribute for POSIXBUILTINS. I merely removed the restriction that readonly variables cannot be exported by adding: && !(on & PM_EXPORTED) Note that the restriction was already inconsistent: this code did not block unset readonly variables from being given the export flag. FWIW, the test suite passes cleanly with this patch. Thanks, - M.