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

Re: Upper case



Andrei Zmievski wrote:

> On Mon, 25 Oct 1999, Geoff Wing wrote:
> > One way:
> > 	mv $i ${${(C)i}:s/Mp3/mp3/}
> 
> Could someone explain this one to me, piece by piece? Obviously,
> s/Mp3/mp3 does a substitution but what is ${${(C)i}} all about?

It's quite simple, actually. In `${name}' substitutions, the `name'
may also be another substitution. The outer one will then work on the
result of the inner one (of course they can be nested as deeply as you 
want). So the `${(C)i}' is a parameter substitution with a flag, the
`(C)'. Such flags not supported by other shells, so I think this is
what really irritates you. Zsh has several such flags, some are
rather baroque, but many are quite useful, see the `Parameter
Expansion' section in the docs (in the `zshexpn.1' man page if you use 
the manual). Sorry, there are too many flags to explain all of them
here.
Anyway, the `${(C)i}' yields the contents of the parameter `i'
capitalized. This string is then used by the `${...:s/Mp3/mp3}' which
just replaces every `Mp3' with `mp3', of course.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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