From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14089 invoked by alias); 4 Feb 2015 00:39:46 -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: 19803 Received: (qmail 26211 invoked from network); 4 Feb 2015 00:39:44 -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 MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=utf-8; format=flowed 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=IkcTkHD0fZMA:10 a=RPO8E_hbvlDCreKbelcA:9 a=QEXdDO2ut3YA:10 Message-id: <54D16A4C.9010609@eastlink.ca> Date: Tue, 03 Feb 2015 16:39:40 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.3.0 To: =?UTF-8?B?TGF3cmVuY2UgVmVsw6F6cXVleg==?= Cc: zsh-users@zsh.org Subject: Re: ${var:1:1:=y} References: <54D155C8.4080600@eastlink.ca> <412544FB-49A2-43AA-BC76-DC1AF1AA71BE@larryv.me> In-reply-to: <412544FB-49A2-43AA-BC76-DC1AF1AA71BE@larryv.me> On 02/03/2015 04:18 PM, Lawrence Velázquez wrote: > On Feb 3, 2015, at 6:12 PM, Ray Andrews wrote: > >> We can of course do this: >> >> variable=${var:=xy} >> >> I'm wanting the naive expansion of that syntax to do this: >> >> variable=${var:1:1:=y} >> >> ... but it doesn't work. Can something like that be done? > (This is admittedly a non-answer, as I don't know whether there's a solution that's as succinct as you'd like.) > > I would find that syntax (or something like it) very ambiguous. What would be assigned "y" in this case — `var`, or the slice of `var` that you were testing? Neither is obvious. Sure, it could end up as a syntactical monster. I'd naively read it: assign to 'variable' either the value of the second character of 'var' (just one character), and if that does not exist, assign 'y'. If you were checking for more than one character and some of them existed, but some not, then things would get fuzzy indeed. Probably better left alone. Just asking.