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

Re: Printing arrays for use with $()



    Hi Dan :)

 * Dan Nelson <dnelson@xxxxxxxxxxxxxxx> dixit:
> Why not use ${(q)array}?  You probably also want to use print -r,
> othersize it will try and parse \-escape codes.
> 
> dan% a=("file name" single\'quote double\"quote)
> dan% echo ${(q)a}
> file\ name single\'quote double\"quote
> dan% echo ${(qq)a}
> 'file name' 'single'\''quote' 'double"quote'
> dan% echo ${(qqq)a}
> "file name" "single'quote" "double\"quote"
> dan% print -l -- ${(qq)a}
> 'file name'
> 'single'''quote'
> 'double"quote'
> dan% print -rl -- ${(qq)a}
> 'file name'
> 'single'\''quote'
> 'double"quote'

    Try, with your example, this:

    du $(print -lr -- ${(q)a})

    or any other of the examples ;) They will fail with exactly the
same problem I'm currently having. The problem is that the "print"
command doesn't quote properly its output (obviously, it has to
*print* it, not quote it to make it munchable for other commands).

    Thanks anyway :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...



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