help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Why not make address@hidden the same as `printf %q' outp


From: Chet Ramey
Subject: Re: [Help-bash] Why not make address@hidden the same as `printf %q' output?
Date: Fri, 27 Oct 2017 14:36:07 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 10/27/17 5:48 AM, Clark Wang wrote:
> See following example:
> 
> $ var=123
> $ echo address@hidden
> '123'
> $ printf '%q\n' $var
> 123
> $
> $ var='1 2 3'
> $ echo address@hidden
> '1 2 3'
> $ printf '%q\n' "$var"
> 1\ 2\ 3
> $
> 
> Any particular reason to implement them differently?

It wasn't a great decision to use backslash quoting with printf %q, but
it's been that way for a long time and I'd rather not change it.  The
transformation operators all use single quoting to quote when needed,
and I think that works better.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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