Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

trying to understand scalar subscripting





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?


Thanks for any help,
Sebastian



Messages sorted by: Reverse Date, Date, Thread, Author