Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.0
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
         :mime-version:content-type;
        bh=iRwHsmDApWHYM6ivXsv33JnZx7/us17XcDOcFbVubFo=;
        b=P+5wWTEqYzw4n4uq8Ts5f654at1XoclDmNVoWiXbyA8yNjB4KjCGO31oN27OWkLb43
         rPb+akCwLG9vp0/TkdKFXGiePII0kRdxHIIjxsQXGe2LWU3SR9SLE0Dh9bAX9p9q8/IH
         B17vK3c+A5XoF4DMGVp1YGoRJTBCyvE0nIcK4W/3G5tJEDvNRXNbMpf3UX05ArnsrQP5
         0Qi7ne0imSM/QMx5Qw3QC9CGYEvTqTUQzzIh8s0TOK3xAlHlZ6/mC4Mdwean/A0HJ+dF
         ExQuBAjoDkLT+Gi+mNT70mtziW9MuQeDVLI1RgpM0hUjAyo4e11zgrnlRY40jsl+mkk3
         Ly8A==
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:mime-version:content-type;
        bh=iRwHsmDApWHYM6ivXsv33JnZx7/us17XcDOcFbVubFo=;
        b=KOjYrOWgSS1ucouqWW0owJ5ks23CtkHAEXYKk+89k8aR89StiCHNxCbJ/3EYiTX1Jd
         SkjuBQhVQBJfPUrRNpgxdnF4xANyqGD4yetcHzSQjOt05K4IdKK7HglwMmYAc3o6t8lJ
         9+BFthU+5XLlc5qeeEiUur36ksQYdGwZAN2jlpardckVGhzHb6Q34jrTyFs3QxrdIyYC
         3FzCCSCtEZ1X6prVRKoCh6MDSkqKQgE8Wc5j3QeIvgVq7sWMdulopx4f6UOsy7ReYODl
         PWHi8Wsj0tjztqjUqprRPMeGJHA4e4myRZjLWdbdhwty6whjOJlOEAxLFWm58XRiHC0g
         0HLA==
X-Gm-Message-State: AG10YOT7QLFIkF+YrreIHjamqtbfAYCl68b+Mz79nEfy08Ms3Og4xnCfZEkg5WN50huCOg==
X-Received: by 10.66.140.14 with SMTP id rc14mr31432828pab.65.1453783673942;
        Mon, 25 Jan 2016 20:47:53 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160125204829.ZM15331@torch.brasslantern.com>
Date: Mon, 25 Jan 2016 20:48:29 -0800
In-Reply-To: <56A6F01E.8030306@inlv.org>
Comments: In reply to Martijn Dekker <martijn@inlv.org>
        "Re: [BUG] quoting within bracket patterns has no effect" (Jan 26,  4:03am)
References: <569C68AB.2010806@inlv.org> 
	<20160118172434.2fb7d5b9@pwslap01u.europe.root.pri> 
	<56A2C6A8.4090108@inlv.org> 
	<160122174949.ZM11794@torch.brasslantern.com> 
	<56A6F01E.8030306@inlv.org>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: zsh-workers@zsh.org
Subject: Re: [BUG] quoting within bracket patterns has no effect
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37784

On Jan 26,  4:03am, Martijn Dekker wrote:
}
} In normal variable expansion, setting the option SH_WORD_SPLIT causes
} unquoted $var to be equivalent to ${~var} in variable expansion.
} Wouldn't it make sense to have SH_WORD_SPLIT activate pattern characters
} in unquoted variables in range expressions as well?

Look again at my first example from the previous message:

schaefer[691] Src/zsh -f
torch% emulate sh
torch% myrange='a-z'
torch% somevar='c'
torch% case $somevar in
case> ( *[$myrange]* )  echo "$somevar is part of $myrange" ;;
case> esac
c is part of a-z
torch% print $ZSH_PATCHLEVEL
zsh-5.2-103-g69c86cd

What about that is incorrect?  You need $~myrange for "emulate zsh" but
NOT for "emulate sh", unless I'm missing something.

Also it's never been "setopt shwordsplit" that enables patterns in a
parameter expansion, rather it's "setopt globsubst":

schaefer[692] Src/zsh -f
torch% x='c*h'
torch% print $x
c*h
torch% setopt shwordsplit
torch% print $x
c*h
torch% setopt globsubst
torch% print $x
config.h config.modules.sh

What I was pointing out when I said "I'm not sure it's possible to have
it both ways" has ONLY to do with "emulate zsh".  The problem is that
the parsing happens at two different places -- at the time $myrange is
expanded, I don't believe the parameter substitution code knows it's
inside a character set in an active pattern; so there's no way to
temporarily activate globsubst except by explicity doing so.

This may be a case where native zsh is incompatible with POSIX at a
fairly fundamental level; old working zsh scripts are potentially going
to break, and I don't think we can do anything about it unless we want
to tell POSIX to go pound sand.

