From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 401 invoked by alias); 17 Nov 2012 23:26:47 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17405 Received: (qmail 7457 invoked from network); 17 Nov 2012 23:26:35 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.eastlink.ca designates 24.224.136.10 as permitted sender) X-Authority-Analysis: v=2.0 cv=TNAd0CZa c=1 sm=1 a=bWgGDZnfoeonEsxmbE2SBg==:17 a=-1ZKr4ocusoA:10 a=UjUtIS2Rs34A:10 a=IkcTkHD0fZMA:10 a=kourTHHxn5YA:10 a=785PRW6w0y6iuGovaU0A:9 a=QEXdDO2ut3YA:10 a=bWgGDZnfoeonEsxmbE2SBg==:117 Message-id: <50A8161D.1030302@eastlink.ca> Date: Sat, 17 Nov 2012 14:56:29 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: ${var: -1:1} vs. ${var:-1:1} References: <50A7FD3C.9070306@eastlink.ca> In-reply-to: Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 7bit On 17/11/12 01:48 PM, Moritz Bunkus wrote: > Hey, > > if you don't put a space there then the parser thinks that this the > "${variable:-default} syntax which means "expands to the variable's > content if the variable is set and to 'default' if it is unset". Can > be seen easily with: > > [0 mosu@sweet-chili ~] echo ${thisvarisnotset:-1:1} > 1:1 > > So the '1:1' is interpreted as the 'default'. You probably never saw > that result because you were trying to extract the last character from > a string, meaning you always used a variable that was set. > > Kind regards, > mosu > I see. But it's still lousy syntax IMHO.