zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Parser issues and and [[ $var ]]
Date: Sat, 26 Apr 2014 13:30:19 -0700	[thread overview]
Message-ID: <140426133019.ZM29630@torch.brasslantern.com> (raw)
In-Reply-To: <slrnlln1bj.a9l.martin@epidot.math.uni-rostock.de>

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.


       reply	other threads:[~2014-04-26 20:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAH_OBicpVKS-URnd-Gq=gj+qc6OhDCqf0mgDfVcda27mEEfUKg@mail.gmail.com>
     [not found] ` <140416102727.ZM19090@torch.brasslantern.com>
     [not found]   ` <CAH_OBic7sX1Oc4VWn2KvX40smbRB6A7w8QGXLvPfZLD=CHMddQ@mail.gmail.com>
     [not found]     ` <534FE710.3020601@eastlink.ca>
     [not found]       ` <140417123722.ZM22179@torch.brasslantern.com>
     [not found]         ` <20140423165024.1480528a@pws-pc.ntlworld.com>
     [not found]           ` <lj984r$6uo$1@ger.gmane.org>
     [not found]             ` <CAHYJk3QOZTnicq+Nqg4BXNANa_c6_j5mhyQNK1f8YNtDhxixgA@mail.gmail.com>
     [not found]               ` <slrnlll0kq.v0i.martin@lounge.imp.fu-berlin.de>
     [not found]                 ` <20140425172112.7bf50606@pwslap01u.europe.root.pri>
     [not found]                   ` <slrnlln1bj.a9l.martin@epidot.math.uni-rostock.de>
2014-04-26 20:30                     ` Bart Schaefer [this message]
2014-05-10 21:09                       ` Bart Schaefer
2014-05-11  1:01                         ` Bart Schaefer
2014-05-11 17:01                           ` Peter Stephenson
2014-05-11 18:12                             ` Bart Schaefer
2014-05-13  5:01                               ` [PATCH] " Bart Schaefer
2014-05-13  9:10                                 ` Peter Stephenson
2014-05-13 15:03                                   ` Bart Schaefer
     [not found]                     ` <20140426212126.58b0ff26@pws-pc.ntlworld.com>
2014-04-26 21:23                       ` More [[ $var ]] (Re: zsh-newuser-install) Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=140426133019.ZM29630@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).