From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24263 invoked by alias); 18 Nov 2012 01:31:56 -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: 17407 Received: (qmail 15415 invoked from network); 18 Nov 2012 01:31:54 -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 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <121117173135.ZM9888@torch.brasslantern.com> Date: Sat, 17 Nov 2012 17:31:35 -0800 In-reply-to: <50A8161D.1030302@eastlink.ca> Comments: In reply to Ray Andrews "Re: ${var: -1:1} vs. ${var:-1:1}" (Nov 17, 2:56pm) References: <50A7FD3C.9070306@eastlink.ca> <50A8161D.1030302@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: ${var: -1:1} vs. ${var:-1:1} MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Nov 17, 2:56pm, Ray Andrews wrote: } Subject: Re: ${var: -1:1} vs. ${var:-1:1} } } > 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". } > } > 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. } > } I see. But it's still lousy syntax IMHO. Well, the var:-word syntax long predates :N:M for string slicing. Zsh actually can (and always has) used just ${var[-1]} for the last character of a string, the :N:M syntax was invented by bash and merely adopted by zsh for compatibility.