From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2055 invoked by alias); 4 Feb 2015 05:47:03 -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: 19807 Received: (qmail 5483 invoked from network); 4 Feb 2015 05:47:00 -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 X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=f7zwPcoQMel2pEJwRS33iw==:117 a=f7zwPcoQMel2pEJwRS33iw==:17 a=Hpgzp-inWqAA:10 a=N659UExz7-8A:10 a=P30pdCHP8rf-J103YmgA:9 a=pILNOxqGKmIA:10 Message-id: <54D1AB46.8050201@eastlink.ca> Date: Tue, 03 Feb 2015 21:16:54 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: ${var:1:1:=y} References: <54D155C8.4080600@eastlink.ca> <412544FB-49A2-43AA-BC76-DC1AF1AA71BE@larryv.me> <54D16A4C.9010609@eastlink.ca> <150203192508.ZM2159@torch.brasslantern.com> In-reply-to: <150203192508.ZM2159@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit On 02/03/2015 07:25 PM, Bart Schaefer wrote: > You've forgotten that ${var=val} has the side-effect of assigning to > "var" if it is not set. No, it was just irrelevant there. > I think what you mean is what Lawrence already > demonstrated (again several messages ahead): > > variable=${${var:1:1}:-y} Ah, I thought it might be like that, one of those 'nested' things. Nothing you can't do with those if you know how. > However, you can do this with subscript syntax: > > variable=${var[2]:=y} > > which either assigns to $variable the second character of $var, or > assigns "y" to both $variable and to the second character of $var. Even softer. > You can also do ${var[2]::=z} to forcibly assign "z" to the second > character of $var. Excellent. > > (Actually the doc might not say exactly that due to a Yodl formatting > error, but that's what it is supposed to say. The part about a single > `-' in a separate word is correct and is what matters here.) Ok, all good. Fact is, I'd not have a clue where I'd look to find that information. Thanks both. >