bug-bash
[Top][All Lists]
Advanced

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

Re: address@hidden expansion includes 0x01 and 0x02


From: Chet Ramey
Subject: Re: address@hidden expansion includes 0x01 and 0x02
Date: Fri, 6 Nov 2015 08:51:30 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/5/15 7:45 PM, Dennis Williamson wrote:

>     That's what the \[ and \] escape sequences expand to and use to
>     communicate information to readline about invisible characters in the
>     prompt (RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE).  If you want to
>     use the expansion of address@hidden as, for instance, the prompt passed to
>     readline when using `read -e -p prompt', those characters need to be 
> there.
> 
> 
> To follow on to what Greg said:
> 
> The only way I've found to output a string containing non-printing sequence
> delimiters using the @P transformation is to use read -e -p or to strip the
> \[ and \] first. All the other prompt escapes work in printf or echo -e
> when using @P.

Let's stipulate that you're talking about interactive shells here, since
line editing is turned off in non-interactive shells, and \[ and \] only
expand to \001 and \002 when line editing is enabled.  (Though what I
describe here works in non-interactive shells, too.)

You can get the results you want by toggling the `emacs' option, or `vi'
if that's what you prefer.

Since \[ and \] expand to special readline characters only when readline
(and therefore line editing) is enabled, and you don't want them expanded,
then you should disable readline.  You can disable line editing with
`set +o emacs +o vi' (whichever is appropriate).

Run the following script to see what I mean:

P='\[vis0\]\w\$\[vis1\] '

echo "address@hidden" | cat -v
set -o emacs
echo "address@hidden" | cat -v
set +o emacs +o vi
echo "address@hidden" | cat -v

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



reply via email to

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