Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: trying to understand scalar subscripting
- X-seq: zsh-users 12761
- From: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- To: "zsh-users ml" <zsh-users@xxxxxxxxxx>
- Subject: Re: trying to understand scalar subscripting
- Date: Fri, 4 Apr 2008 23:12:23 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=CNriEFxUHp8nXzcVhRBy87xmRjo+5DOAzaoHb0QEn98=; b=B0kJ+yl2SS6RdWqxQLtiULX3CF5PKLA/ZNFiHUzbsI27eunBxuWsH/ZQmotNBHQTmoUJXlypyudh3iaCvqq5Mao3S8niGdaRhvwLGTTgJDIRYv3OAr3iHaG8BDL45LRqni4D14BcCFUsM9HQSBPfilFeDXXyCIfI4selT9nLAGw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Ue8v4ESUR9sGeszuGn13vITXY4UH+ZaeiA/rPrDCkrSrHTzZFqKpRT+gb7BQ3ahpw349jUTNgtRx6oxlIgTudT2jeJZFxrgM85xIPcgCQMrZC8/kxqYzhYchXkVObyq67x/X9MYYLeBUP1UbzwrIMKyFMp+pQVBunu1NDAwTvfI=
- In-reply-to: <56DB95A0-5998-48ED-BAEC-02420B632CB8@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <56DB95A0-5998-48ED-BAEC-02420B632CB8@xxxxxxxxxxx>
On 04/04/2008, Sebastian Stark <seb-zsh@xxxxxxxxxxx> wrote:
>
>
> In zshparam(1) I read about the possibility to subscript scalar parameters.
> Maybe somebody can help me understanding this.
>
>
> Fist I set aaa to some scalar value and print it:
>
> % aaa="fasdf gaag sdlkfjh dsfsags"
> % print -l $aaa
> fasdf gaag sdlkfjh dsfsags
>
> That was expected. Now I expand all elements of the parameters:
>
> % print -l $aaa[*]
> fasdf gaag sdlkfjh dsfsags
>
> Okay, not quite expected. I thought this would print all the characters in
> aaa in a separate line each. But this still does not confuse me enough. So I
> try a subscript range:
>
> % print -l $aaa[1,3]
> fas
>
> This was kind of expected. Now I try to use the w and s:: subscript flags.
> zshparam(1) says they should work with scalars:
>
> % print -l $aaa[(ws:a:)1,3]
> fas
>
> Hm. I thought that would do word splitting because of (w) and also use ,a`
> as the separator instead of , `. But what really confuses me is this:
>
> % print -l $aaa[(ws:a:)*]
> zsh: bad math expression: operand expected at `*'
>
> Huh? One could say what I am doing is completely silly, but when I try to
> do this with a real array I get the same error message:
>
> % bbb=(fasdf gaag sdlkfjh dsfsags)
> % print -l $bbb[(ws:a:)*]
> zsh: bad math expression: operand expected at `*'
>
> I did this with zsh-4.3.4. Is all that expected behaviour? Should I try
> zsh-4.3.6?
I get the same result as you with your commands, running on 4.3.6. I
don't know why it doesn't work or if it should, but this expression
will give the result you presumably want:
print -l ${${(s:a:)aaa}[*]}
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author