[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: \c-handling in $'-strings
From: |
Chet Ramey |
Subject: |
Re: \c-handling in $'-strings |
Date: |
Wed, 2 Sep 2015 09:19:29 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 9/1/15 6:46 PM, Helmut Karlowski wrote:
> Do you refer to the table titled "Circumflex Control Characters in stty"?
>
> It states for example:
>
> ? <DEL>
Yeah, that's a problem. I've fixed that.
>
> Running:
>
> echo $'\c?' |od -a
> echo $'\c[\c\\c]\c^\c_\c?' |od -a
>
> bash prints:
>
> 0000000 us nl
> 0000002
> 0000000 esc fs c ] rs us us nl
>
> I'd expect:
>
> 0000000 del nl
> 0000002
> 0000000 esc fs gs rs us del nl
>
> Also the ] in the output seems wrong, looks it gets the \\ wrong, though
> ksh93 does this also.
The Posix standardization of $'...' requires that the character after the
`\c' honor backslash escaping. Since the character becomes \c\\, the
subsequent `c' and `]' are literals.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/