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

Re: quoting words



I think I found a way

a=(sa\ bb cc\ dd); a=${(qq@)"${a[@]}"}; typeset -p a; echo -e $a
typeset a='''sa bb'' ''cc dd'''
'sa bb' 'cc dd'

sorry for the bother

Pier Paolo Grassi


Il giorno mar 28 set 2021 alle ore 13:35 Pier Paolo Grassi <pierpaolog@xxxxxxxxx> ha scritto:
Hello, I have something like
a=('aa bb' 'cc dd');

and I would like to get the quoted representation inside a string, so that

echo -e $b
'aa bb' 'cc dd'

or that

typeset -p b
gives
'''aa bb'' ''cc dd'''

I tried with

a=(sa\ bb cc\ dd); b="${(q+)a[@]}"; typeset -p b
typeset b='''sa bb cc dd'''

and other inconclusive variations

Pier Paolo Grassi


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