From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16624 invoked by alias); 26 Apr 2014 20:30:44 -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: 32586 Received: (qmail 11341 invoked from network); 26 Apr 2014 20:30:37 -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 From: Bart Schaefer Message-id: <140426133019.ZM29630@torch.brasslantern.com> Date: Sat, 26 Apr 2014 13:30:19 -0700 In-reply-to: Comments: In reply to Martin Vaeth "Re: zsh-newuser-install" (Apr 26, 10:07am) References: <140416102727.ZM19090@torch.brasslantern.com> <534FE710.3020601@eastlink.ca> <140417123722.ZM22179@torch.brasslantern.com> <20140423165024.1480528a@pws-pc.ntlworld.com> <20140425172112.7bf50606@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Parser issues and and [[ $var ]] MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Apr 26, 10:07am, Martin Vaeth wrote: } } BTW: "emulate -L bash" would be useful to read some distribution's } or user's bash setup files. Main difference to emulate -L sh would be } setopt ksh_glob no_sh_glob brace_expand } and that [[ $var ]] is treated equivalent to [[ -n $var ]]: } I experienced that the latter is the main issue with bash compatibility } (besides shopt and PS1, of course, which are not reasonable to emulate). Hmm. Looks like both bash and ksh93 accept [[ $foo ]] as valid syntax. This turns out to be surprisingly difficult to fix, and poking at it, I think we may have broken some things in parse.c. For example, [ -t ] is supposed to be equivalent to [ -t 1 ] and there is code late in par_cond_2() that handles this, but that code is never reached because the /* POSIX 1003.2 */ code at the top of par_cond_2() preemptively turns it into [ -n -t ]. The same unreached code for [ -t ] also tries to handle [ $var ] but is not usable for [[ $var ]] because of the different lexing conventions for "test"/"[" vs. [[ ... ]]. Also [[ -t ]] is NOT supposed to behave like either of [[ -t 1 ]] or [[ -n -t ]], so that part of the code in question must be avoided. Also, if you compare the later code to the earlier code, sometimes we call dupstring() on the first argument to par_cond_double() and other times we do not. Either we don't need dupstring(), or not using it is a bug waiting to happen. So it looks like par_cond_2() needs some more overhauling.