Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${var:1:1:=y}
- X-seq: zsh-users 19804
- From: Lawrence Velázquez <vq@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: ${var:1:1:=y}
- Date: Tue, 3 Feb 2015 20:30:26 -0500
- Cc: zsh-users@xxxxxxx
- 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=kyK/B3R/MvD5/w+2v0GZzsyUbY4=; b=ljZtiiWa+zYV2ixO4Ng7V +nGCTMFNLlhardplU0JmilPUwyXopX5uQtZ4zvwmSw6wDn+iNKn1Ud5Sx463aqE/ i11m+4OFgRrAfo4GsW1KGonTA9/5OswNqPDuLP/i8ELbIjMw4eiy/WZyO2f/Swuu wYzKlBhSDRz1TFW6Cw8UZU=
- 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=kyK/B3R/MvD5/w+2v0GZzsy UbY4=; b=eTMlls3JDsghXowyK89+yl7th6vFjJhOwiadQTSRrben55ME8cfJShh bvfDv+uSkMgszkWoSrUD2N0nmP6z/gZa6TCSDIeJpSMA5I4lGbG2ULwnMg+ybKNS isXM95aiaaNFeOVFbQJfFjQxNneDzVpSJILa34IrUdn6e0LPz3Jo=
- In-reply-to: <54D16A4C.9010609@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <54D155C8.4080600@eastlink.ca> <412544FB-49A2-43AA-BC76-DC1AF1AA71BE@larryv.me> <54D16A4C.9010609@eastlink.ca>
On Feb 3, 2015, at 7:39 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> 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'.
See, that interpretation didn't occur to me at all :)
From zshexpn(1):
If a ${...} type parameter expression or a $(...) type command
substitution is used in place of "name" above, it is expanded first
and the result is used as if it were the value of "name".
So you'd probably want something like this, except with variable
assignment instead of `echo`:
% foo=
% echo ${${foo:1:1}:-y}
y
% foo=a
% echo ${${foo:1:1}:-y}
y
% foo=abcdef
% echo ${${foo:1:1}:-y}
b
%
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author