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

Re: Fun zsh trick for today



On Jun 14,  3:15pm, Peter Stephenson wrote:
} Subject: Re: Fun zsh trick for today
}
} Plus you don't need all those (@)'s once parameter substitution already has
} arrays, which (f) provides.  The only trick here is using double quotes to
} get whole lines for splitting.  I think the following should work in 3.0.8
} (can't quite remember if the trick of putting double quotes in the middle
} made its way back

The quotes in the middle is in 3.0.7, as part of the "minimal forwards
compatibility" effort.

There is a small bug with them in both versions, though; you can't take
the length of the quoted part:

zagzig[57] echo ${#"${(f)$(<file)}"}
zsh: bad substitution
zagzig[60] echo ${#${"${(f)$(<ChangeLog)}"}}
8017

It works with ${=...} and ${~...}, but not with ${#...}.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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