From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23368 invoked by alias); 27 Nov 2014 21:38:56 -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: 33814 Received: (qmail 250 invoked from network); 27 Nov 2014 21:38:55 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=MJ3XQ3dg c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=5y4faFyK3SkA:10 a=fLCu2ocWttWUlB9YHNIA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <141127133833.ZM6853@torch.brasslantern.com> Date: Thu, 27 Nov 2014 13:38:33 -0800 In-reply-to: <20141127204349.036d3807@pws-pc.ntlworld.com> Comments: In reply to Peter Stephenson "Re: Inconsistency of GLOB_ASSIGN" (Nov 27, 8:43pm) References: <141126215725.ZM13054@torch.brasslantern.com> <20141127204349.036d3807@pws-pc.ntlworld.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Inconsistency of GLOB_ASSIGN MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Nov 27, 8:43pm, Peter Stephenson wrote: } Subject: Re: Inconsistency of GLOB_ASSIGN } } It would be neater always to do an array assignment, in fact, but } the traditional behaviour is that if there was only one result the } assignment is scalar, and GLOB_ASSIGN is really there only for } tradition. That's too bad, because making it always be an array assignment is a lot simpler than figuring out whether the glob expanded to something. (I think. Still pondering.) There are also very few contexts where a single-element array and a scalar behave differently. The only one I can think of would be subscript slices, but if you're glob-assigning to a variable and then expecting to be able to subscript it as a string, you're already in pretty strange territory. One interesting thing is what happens with NO_NOMATCH. A failed glob still returns a single-element array in that case, whereas a string containing no globbing characters is a scalar. } Arguably we should look at the type of the destination and if it's } numeric not do a glob at all. I'd be happy with that, since: } } integer x } x=3*3 } } probably doesn't mean "look for files beginning and ending in 3" The "happy" behavior is already the case for NO_GLOB_ASSIGN, so I think it's OK to ignore the type of the variable when the value is asserted to be a glob.