Re: suggestion to avoid erroneous lines in findmnt/lslocks/...

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

 



On Wed, Aug 08, 2012 at 12:36:05AM +0100, Pádraig Brady wrote:
> ck\slash is not \x<xdigit> sequence, so escape is unnecessary
> > 
> >  Note that \\server\path is pretty common for cifs and use \x5c
> >  for all '\' will make the findmnt output unreadable in many cases.
> >  IMHO is better to be "smart" and use escape sequences only when it's
> >  really necessary.
> 
> Better for humans, but awkward for scripts to parse.
> What I was thinking was perhaps --raw or -P would
> do unconditional escaping of '\' so unescaping can be
> done with just `printf %b`?

 Good point. Fixed, all '\' will be replaced with \x5c.

> With the conditional escaping you'd have to do something like:
> 
> unmangle() {
>   printf '%b' $(
>     sed '
>       s/\\\([^x]\)/\\x5c\1/g;
>       s/\\\(x[^0-9a-f]\)/\\x5c\1/g;
>       s/\\\(x[0-9a-f][^0-9a-f]\)/\\x5c\1/g;
>     '
>   )
> }

 ugly, I see, let's use printf '%b' without the sed stuff. Thanks.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux