help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Transform strings with special characters so that the st


From: Eric Blake
Subject: Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?
Date: Thu, 26 Mar 2015 07:00:39 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

On 03/26/2015 06:56 AM, Chet Ramey wrote:
> On 3/25/15 5:42 PM, Eric Blake wrote:
>> On 03/25/2015 03:26 PM, Eric Blake wrote:
> 
>>>>> printf -v escaped_var %q "$var"
>>>
>>> Fork-free.
> 
>> But requires bash extensions ('printf -v var' and 'printf %q' are
>> both bashisms not likely to work in other shells)
> 
> It's help-bash, after all.  I don't think people mind bash solutions.

True, but calling it out makes it easier to compare why bash solutions
are nice (the amount of code required to get a solution in portable
shell is so much greater that it should be an obvious choice that bash
extensions are worth relying on).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
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]