bug-bash
[Top][All Lists]
Advanced

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

Re: ${var@P} expansion includes 0x01 and 0x02


From: Chet Ramey
Subject: Re: ${var@P} expansion includes 0x01 and 0x02
Date: Wed, 28 Oct 2015 09:55:17 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 10/27/15 5:02 PM, Greg Wooledge wrote:
> I decided to play around with the ${var@P} expansion in 4.4-beta.
> 
> imadev:~$ red=$(tput setaf 1) reset=$(tput sgr0) 
> x='\[$red\]\u\[$reset\]@\h:\w\$ '; printf %s "${x@P}" | od -t x1
> 0000000    1  1b  5b  33  31  6d   2  77  6f  6f  6c  65  64  67   1  1b
> 0000020   5b  6d   f   2  40  69  6d  61  64  65  76  3a  7e  24  20
> 0000037
> 
> I don't think the "1" and "2" bytes should be printed.  They're for
> internal use only, even if they're usually invisible.

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 ${var@P} as, for instance, the prompt passed to
readline when using `read -e -p prompt', those characters need to be there.

-- 
``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/



reply via email to

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