From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15958 invoked by alias); 10 Mar 2013 20:45:08 -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: 31142 Received: (qmail 20760 invoked from network); 10 Mar 2013 20:45:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 209.85.212.175 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-proxyuser-ip:date:from:to:subject:message-id :in-reply-to:references:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=+SdCzIDzRzwOllG7x0yvf+CZFsGHzDju2lHJc5ZJPj8=; b=Y9Wa2rLRWTVcaMreQ4qYTMgaBh2qfkXy+FUpSVRuylPpRndn8BQvo4ynhtfe/eu3YO aobFCv12mMAq0x1l7OpTIUsgll27jXW289+vbJKzGzBoB8+e38K7ZhlvRTRSz1eXTT0c N1tJhksNxzlC4EpywAQBajehnwV9ieERkcBs9pAJERMzoOjWnlpGDQ/NqGObcWH8LWn8 buChzN3pdUr1lths4uz/e/Xfgbq+uFUVu/eCiGXt9uYPDejoz7Bg0YVeNABxBdr5pw4p Q1Av0tMe+Pj8pL9ZIx+vaTL0DbRiwQH+zh1WlmDqrbKEQFZA9XYdeRs8I4IbGXtVL4vx aTrQ== X-Received: by 10.180.75.143 with SMTP id c15mr8407881wiw.18.1362941527624; Sun, 10 Mar 2013 11:52:07 -0700 (PDT) X-ProxyUser-IP: 86.26.6.143 Date: Sun, 10 Mar 2013 18:52:04 +0000 From: Peter Stephenson To: zsh workers Subject: Re: Somewhat unexpected results of {myfd}>&1 when noclobber set Message-ID: <20130310185204.47d755e8@pws-pc.ntlworld.com> In-Reply-To: <130309071252.ZM19892@torch.brasslantern.com> References: <130309071252.ZM19892@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQkmjAkTkGyljjNfdBn9V9VJHZWygjE1GN3qmFmXPXwQXwNfcV/pKRK9kfmb4/IJZVoWuScM On Sat, 09 Mar 2013 07:12:52 -0800 Bart Schaefer wrote: > On Mar 9, 11:33am, Mikael Magnusson wrote: > } > } % bar=( 14 15 ) > } % : {bar}>&1 > } zsh: bad math expression: operator expected at `15' > } % echo $bar > } 16 > > This is clearly a bug. Failing the math eval should either abort the > entire operation, or not print the warning. I think the latter would > be considered the intended behavior, that is, bar does not contain a > descriptor so it simply gets assigned a new one by the redirection. I suppose so, it's consistent with % setopt noclobber % foo=fictional % exec {foo}>&1 % print $foo 11 But I think Michael's right that to get that effect we don't want the matheval at all --- we just want to see if foo contains an integer (it looks like we also check if it's a previously opened fd after retrieving it). We're only interested in whether foo has previously been set to an actual descriptor, not to something that might in future evaluate to a descriptor, which wouldn't make sense. So if "foo=10+1" it's also not a descriptor (can't be the result of a previous fd-open-and-assign-to-variable) and so can be clobbered. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/