From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21482 invoked by alias); 3 Sep 2014 15:44:55 -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: 33106 Received: (qmail 21035 invoked from network); 3 Sep 2014 15:44:52 -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: <140903084448.ZM16438@torch.brasslantern.com> Date: Wed, 03 Sep 2014 08:44:48 -0700 In-reply-to: Comments: In reply to Clint Hepner "The ~ parameter expansion flag: bug or misunderstanding" (Sep 3, 10:58am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: The ~ parameter expansion flag: bug or misunderstanding MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 3, 10:58am, Clint Hepner wrote: } } My reading of the ~ flag leads me to believe that you can replace the } literal string with a pattern, so that } } % print -l ${(~s.[12].):-a1b2c} } a } b } c No, that's not what the flag means. It means that after the expansion of the parameter has been completed, any pattern characters inserted into the result are active (i.e., not considered quoted). It doesn't otherwise change the operation of the other flags themselves. This doesn't have any effect for the (s) flag because (s) removes characters from the result, rather than inserting them. The purpose of the (~) flag is really to work with the (j) flag, so that you can create a pattern from an array without having any other pattern characters in the values of the array also become active. It also works with (l) and (r), though the uses for treating padding as pattern characters are pretty obscure. To use a pattern for processing the value during expansion, you need to use the trailing // notation, e.g. % print -l ${=${:-a1b2c}//[12]/ } or % print -l ${(s:1:)${:-a1b2c}//[12]/1}