From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10663 invoked by alias); 9 Sep 2014 16:41:17 -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: 33134 Received: (qmail 8336 invoked from network); 9 Sep 2014 16:41:14 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7f776d000003e54-aa-540f2da6f169 Date: Tue, 09 Sep 2014 17:41:09 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: The ~ parameter expansion flag: bug or misunderstanding Message-id: <20140909174109.038d3b3e@pwslap01u.europe.root.pri> In-reply-to: References: <140903084448.ZM16438@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42I5/e/4Fd1luvwhBtMamCwONj9kcmD0WHXw A1MAYxSXTUpqTmZZapG+XQJXxuor7ewFj9grXv+Yw97A2M7WxcjJISFgIvFn3i4mCFtM4sK9 9UBxLg4hgaWMEsvevIdyljNJzF1wFayDRUBVYtqee2AdbAKGElM3zWYEsUUExCXOrj3PAmIL C7hI7Og5yA5i8wrYS+w9egesnlMgWKJj63pmEFtI4CSjxIWHyiA2v4C+xNW/n6CusJeYeeUM I0SvoMSPyffAZjILaEls3tbECmHLS2xe85Z5AqPALCRls5CUzUJStoCReRWjaGppckFxUnqu kV5xYm5xaV66XnJ+7iZGSBB+3cG49JjVIUYBDkYlHt6JZXwhQqyJZcWVuYcYJTiYlUR4rV8A hXhTEiurUovy44tKc1KLDzEycXBKNTAeLsyS5Wr4wVWrzF4/Q3p7HXvUlcnRaj+P/C//dnyH zRrfU57SF1dWXzy6T1cn51fWPOPgtEsLMnR3TjuwtFv5U09UVOTzWzd+zGwXXsoqJDfjxTHe n9W3HvxY/PXcHvv9VtfbVBrnaehOu95j80Fje/HJXotKW9+Oo/KvM395ba33nyNaZZuvxFKc kWioxVxUnAgAKpn0rCACAAA= On Tue, 09 Sep 2014 12:21:16 -0400 Clint Hepner wrote: > Thanks. One thing I still can't quite wrap my mind around is a scenario > where > > ${(j.|.)~array} > > and > > ${~j.|.)array} > > would behave differently. It depends on the contents of array. Here's the sort of scenario that caused the ~ inside the parentheses to be added. Supposing someone has helpfully created a file "a|b", and your array is a list of files in the current directory, array=(*) so it contains an alement "a|b". zsh with its default settings usually handles that fine because it makes a point of not expanding the results of variable substitutions as patterns for exactly this reason. However, when you do ${(j.|.)~array} it looks like two alternatives, a or b, because the "|" in the value of $array is expanded. If you do ${(~j.|.)array}, on the other hand, the "a|b" is kept with the | as an ordinary character, so it still works. pws