[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yet another quoting question

From: Eric Blake
Subject: Re: Yet another quoting question
Date: Fri, 06 May 2011 09:11:28 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

On 05/06/2011 09:02 AM, Steven W. Orr wrote:
>  4.0.35(1)-release (x86_64-redhat-linux-gnu)
> I have a bunch of arrays, and some of the arrays' values are null or
> might contain spaces.

printf %q is your friend.

$ a[0]=aaa a[1]= a[2]='bbb  ccc'
$ printf '%q ' "address@hidden"
aaa '' bbb\ \ ccc

> I'd love to see an elegant solution. :-)

OK, so printf %q prefers '' and \ over "", but the end result is an
unambiguous array listing that can be fed back into shell code.

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]