From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28813 invoked by alias); 17 Nov 2012 21:57:36 -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: 17404 Received: (qmail 12611 invoked from network); 17 Nov 2012 21:57:34 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at bunkus.org does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bunkus.org; s=mail201203; t=1353188939; bh=+r09fDbwoMef+1rrvgOfpdql8KgftMfxJv/fKkT5xCY=; h=MIME-Version:In-Reply-To:References:Date:Message-ID:Subject:From: To:Cc:Content-Type; b=AdjJZm9SE9+xoqmpp8EUhaWd0PmaKFrNZ2JXCXaisL8vpChaeMCA+KqqN8iMvmaeK lCB/SWQaK+2+JX6D2uAo4btr4X9N8Ffx7Ra+s0zAcm6S+N6jPtwG8vfvcapY6uEtpT AsWrLIy5PbbW3DRQHHDiDssNT6Vkekr61dXSRsB4= MIME-Version: 1.0 In-Reply-To: <50A7FD3C.9070306@eastlink.ca> References: <50A7FD3C.9070306@eastlink.ca> Date: Sat, 17 Nov 2012 22:48:56 +0100 Message-ID: Subject: Re: ${var: -1:1} vs. ${var:-1:1} From: Moritz Bunkus To: Ray Andrews Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 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