X-Spam-Check-By: sourceware.org Message-ID: <4e41f5c20704041854r121006f8i37805af31b6ccae3@mail.gmail.com> Date: Wed, 4 Apr 2007 19:54:52 -0600 From: "Morgan Gangwere" <0 DOT fractalus AT gmail DOT com> To: cygwin AT cygwin DOT com Subject: Re: Escape colour codes In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4613A562 DOT 5090806 AT byu DOT net> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com "and this children is why we stick to rxvt and puttyCyg!" On 4/4/07, Matthew Woehlke wrote: > Eric Blake wrote: > > The bug in all three of these programs is that they are adding spurious \1 into > > the string passed to readline. When you call readline("\001\001invisible\001 > > \002plain"), then readline assumes that anything between the FIRST \001 and the > > \002 is invisible (ie. special to the terminal instead of literal output). So > > readline thinks that it should PRINT the invisible string "\001invisible\001" > > special to the terminal, followed by the visible string "plain". However, as > > you noticed, \001 is NOT special to the cmd.com terminal, and results in a > > smiley face, and readline is now thoroughly confused (it thinks it is waiting > > for input on position 6, but in reality it is waiting for input on position 8, > > because you printed literal characters while claiming they were invisible). > > > > Bash, on the other hand, DOES map \[ to the sequence '\001\001' inside of > > parse.y's decode_prompt_string(), BECAUSE it later calls expand_prompt_string() > > to get rid of the extra \001. It needs to do this so that it can support > > PS1='$(foo)' (the prompt is the expansion of command foo), and needed a way to > > tell \[ and \] in PS1 apart from literal \001 and \002 resulting from the > > expansion of other elements in the prompt string. When the prompt is finally > > expanded and ready to hand to readline, the extra \001 _used by bash_ is gone, > > leaving only the SINGLE \001 _used by readline_. In other words, the common > > bug in all three programs you mentioned is that they copied bash's escape > > sequences, but NOT bash's round of internal expansion, prior to calling > > readline. The comment in the lftp sources was rather revealing - if the coder > > didn't know why bash used an extra \001, they shouldn't have copied that. > > Given that three separate programs had *the same bug*, and given that > bash is perhaps the most visible readline user, maybe it would be > worthwhile to mention (briefly) in readline's doc to *not* copy bash's > extra \001 in your own implementation? :-) > > Anyway, I'm glad this was resolved without my (mis)help interfering too > much. :-) > > -- > Matthew > "Will somebody get this walking carpet out of my way?!" -- Princess Leia > Organa > > > -- > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > Problem reports: http://cygwin.com/problems.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ > > -- Morgan gangwere "Space does not reflect society, it expresses it." -- Castells, M., Space of Flows, Space of Places: Materials for a Theory of Urbanism in the Information Age, in The Cybercities Reader, S. Graham, Editor. 2004, Routledge: London. p. 82-93. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/