From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 218 invoked by alias); 29 Oct 2016 01:58:36 -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: X-Seq: 39754 Received: (qmail 3579 invoked from network); 29 Oct 2016 01:58:36 -0000 X-Qmail-Scanner-Diagnostics: from mail-ua0-f174.google.com 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(209.85.217.174):SA:0(0.0/5.0):. Processed in 0.939602 secs); 29 Oct 2016 01:58:36 -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=0.0 required=5.0 tests=SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.217.174 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject:cc :mime-version; bh=tvws7QapYpe7/kG9GGOq7ZXIpPpjnDZ5o6yw+9KH/vM=; b=IubmHsGZOfb19kHyjRKfi8hbaUWXQyUm0033roKIITAozaVek9MLic1uNaw/Cj4Oms Gme46scieGmsNll/wKtFqF2+yiPSQGAcPkguJ+GXwmmNp3NLFhJBQFNXYT1jo3lIvfAq fSpn0Q8Yn8Vzqcs7FVw3mRD6stczL4rqxu61Rws/cqZZfTxShT3N5mBwWX1U2BEoEMdK dK5Htq4tY/t7wyVTcDcjxy3rBtjxA7Ma6RVfEQearR5ofadipCnmYbUezv4m8RNiikPD urQoKYPbIsWOC1HRQ8o7Uhkn5uD78YbLL9GiPrpeyVaXAt7U4T5filucgKtdqL6GbPGn ehAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:cc:mime-version; bh=tvws7QapYpe7/kG9GGOq7ZXIpPpjnDZ5o6yw+9KH/vM=; b=kaZTr3HmMnT2ieg37GV8OUQTN0JNlLXQs7hxFobjFFaRD7bu5sFqwI30rdRKYGI6C/ vdRFETDdNaYnsZj+2tOMlW8pLUOR523R/BSs3zoyHQc4bQV4ZS/Ejun1Q98N4mq7hpeh VCIAbpep4nUt4aIMsNWwSVtz4mhkRIxtwVkNIgRRApkAMSx2clhnjjqs94YZceJQb8sQ qSIFg0fuqNMVjfM3khhtF16/dJ7JjVsWCBZ5YJSUvHstmB6fVXD8wWE5hH0MFOndvsxX LNwKxz347F2301kHIfBPcSkWEwFBJpi1etj+tb7M4JN79emLq8hiyMVqdwPV22ekyhCi EEdg== X-Gm-Message-State: ABUngvdsAxwjzuqukEXFaQuenOdiCI7zSJYhD5IjRguZPLwobJVxK13H6Kfp+Tv8EApNiQ== X-Received: by 10.176.80.209 with SMTP id d17mr13937552uaa.121.1477700323317; Fri, 28 Oct 2016 17:18:43 -0700 (PDT) From: Bart Schaefer Message-Id: <161028171859.ZM2366@torch.brasslantern.com> Date: Fri, 28 Oct 2016 17:18:59 -0700 In-Reply-To: Comments: In reply to Martijn Dekker "Re: exported unset variables [was: 'export -p' lacks POSIX output]" (Oct 28, 10:48pm) References: <9a5b08ae-f45b-d1df-9b3b-dd47a0f62412@inlv.org> <161028143156.ZM19947@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh hackers list Subject: Re: exported unset variables [was: 'export -p' lacks POSIX output] Cc: Martijn Dekker MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii [It's once again taking a long time for some messages to reach the mailing list. My first message on this thread hasn't even shown up there yet.] On Oct 28, 10:48pm, Martijn Dekker wrote: } } $ PS1='%% ' Src/zsh -f -o posixbuiltins } % unset -v var } % export var } % echo ${var+s} # this shows it as set (should be unset) } s } % export -p var # but this shows it as unset } export var Ah, I see. Yes, I mentioned this in the email about the patch. The shell variable named "var" becomes set upon being exported, but the environment copy remains unset until explicitly assigned. Zsh has always distinguished the shell variable from the exported variable, even though the value of the exported variable (if any) is stored in the data structure for the shell variable. All my patch did was cause "export -p" to output the state of the environment variable instead of the state of the shell variable. See if the patch below will help. } (Also, is it correct/expected behaviour that zsh doesn't parse comments } on the interactive command line? Blindly copying/pasting the above won't } work for that reason.) Yes, the option INTERACTIVE_COMMENTS has to be set to recognize comments at the command line. Should this be on in POSIX mode? diff --git a/Src/builtin.c b/Src/builtin.c index 2db739f..183ed45 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -2008,11 +2008,12 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), * handled in createparam(). Here we just avoid using it for the * present tests if it's unset. * - * POSIXBUILTINS horror: we need to retain the 'readonly' flag - * of an unset parameter. + * POSIXBUILTINS horror: we need to retain the 'readonly' or 'export' + * flags of an unset parameter. */ usepm = pm && (!(pm->node.flags & PM_UNSET) || - (isset(POSIXBUILTINS) && (pm->node.flags & PM_READONLY))); + (isset(POSIXBUILTINS) && + (pm->node.flags & (PM_READONLY|PM_EXPORTED)))); /* * We need to compare types with an existing pm if special, @@ -2135,7 +2136,8 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), /* * Stricter rules about retaining readonly attribute in this case. */ - if ((on & PM_READONLY) && (!usepm || (pm->node.flags & PM_UNSET)) && + 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) &&