From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22688 invoked by alias); 4 Feb 2015 00:28:06 -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: 19802 Received: (qmail 25285 invoked from network); 4 Feb 2015 00:28:02 -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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=larryv.me; h= x-sasl-enc:content-type:mime-version:subject:from:in-reply-to :date:cc:content-transfer-encoding:message-id:references:to; s= mesmtp; bh=rEdVKSMbKNFUy5s7OLUcCamVKUE=; b=XK8mfMSKB+RaZyM72WgEJ lmGzLq0OFqZZj+dGSdu8DinQ8WiPbHBbeUAepltDalZ0dPG0aSZ3daisd0ds7GTk Pd4SHeiN4MtA5a6BzHbhcD87TH369BiG2QyRfJ2IiFuUPcD6DpuZ/pFOgqfh6p5g MY6KDOQSr/hTRGVEaI6h/U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:content-type:mime-version :subject:from:in-reply-to:date:cc:content-transfer-encoding :message-id:references:to; s=smtpout; bh=rEdVKSMbKNFUy5s7OLUcCam VKUE=; b=ejeqEVXld5xabi3nMrQ0PHROsGl+WK3EY3X/8+pzHvzqBn+MbLRQlva ifRRWxbo5LzmUqghmkSy8hUvyddPb1mkPgvTBdolK6N9UidhswQsE8aRGz8lWl1c jDqPxLo0Uw6Gua6QETiAQ8ptbu+op8XwAGHCkJsACcop7Has8wk4= X-Sasl-enc: fjTap3c+Kp5he0xyQdb8hWj7jRyZv6dLcZTxBlqBpXbY 1423009116 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) Subject: Re: ${var:1:1:=y} From: =?utf-8?Q?Lawrence_Vel=C3=A1zquez?= In-Reply-To: <54D155C8.4080600@eastlink.ca> Date: Tue, 3 Feb 2015 19:18:36 -0500 Cc: zsh-users@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: <412544FB-49A2-43AA-BC76-DC1AF1AA71BE@larryv.me> References: <54D155C8.4080600@eastlink.ca> To: Ray Andrews X-Mailer: Apple Mail (2.2070.6) On Feb 3, 2015, at 6:12 PM, Ray Andrews wrote: > We can of course do this: >=20 > variable=3D${var:=3Dxy} >=20 > I'm wanting the naive expansion of that syntax to do this: >=20 > variable=3D${var:1:1:=3Dy} >=20 > ... 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 =E2=80=94 `var`, or the slice of = `var` that you were testing? Neither is obvious. > At the moment I'm doing this: >=20 > variable=3D${var:1:1} > [ -n "$variable" ] || variable=3Dy >=20 > ... which is perfectly fine, but the above pseudosyntax would be = elegant if it could be made workable. Wouldn't testing the length of `variable` express your intent better? > And I found something that puzzles me: >=20 >=20 > test () > { > echo $1 > echo ${1:0:1} > /bin/echo ${1:0:1} > echo ${1:1:1} > echo ${1:0:1}${1:1:1} > echo ${1:1:1}${1:0:1} > } >=20 > $ test -a >=20 > -a > [nothing] > - > a > -a > a- >=20 > ... If I entered a valid switchofcourse I'd expect that to be eaten > but a solitary dash? Bug? /bin/echo behaves as I'd expect. Test cases should focus on the questionable behavior by discarding = irrelevant details. Your case boils down to this: % echo - % /bin/echo - - % vq=