public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* odd bash wrapping due to ansi codes
@ 2000-09-17  2:07 Chris Abbey
  2000-09-19  7:10 ` Robert Praetorius
  0 siblings, 1 reply; 14+ messages in thread
From: Chris Abbey @ 2000-09-17  2:07 UTC (permalink / raw)
  To: cygwin

environment is a clean install of 1.1.4 from the "latest"
as of 7 Sept, window is set to 132 columns wide, $COLUMNS is
also set to 132. PS1 is set to:
'<0x1b>]0;\w<0x07><0x1b>[1m<0x1b>[34m\w<0x1b>[0m $ '

cd /tmp
mkdir -p 
one/two/three/four/five/six/seven/eight/nine/ten/eleven/twelve/thirteen/fourteen/fifteen/sixteen/seventeen/eighteen/nineteen/twenty/twentyone/

{wrapping bug #1: mkdir command is wrapped between x and t of sixteen,
at column 110}

cd one/
cd two/
cd ...

repeating this by means of: "up arrow, esc, backspace, tab, enter"

after cd ten you'll see wrapping bug #1b,
   command is wrapped at column 61

after cd eleven you'll see wrapping bug #2,
   prompt is wrapped at column 58

each cd after that you'll see the prompt is
   wrapped *earlier* than before

until after cd eighteen, when it tries to wrap at
   a negative column and the result is some binary
   looking junk in the prompt. This is also the point
   where the titlebar stops being in sync; it appears
   that from here forward each prompt begins with the
   trailing junk that's been truncated from the titlebar.

if the titlebar manipulations are removed from PS1 then
everything goes well up until cd eighteen and nineteen,
where there are some issue with crlfs being left out, but
once you get past there then the prompt is properly wrapped
and everything is ok.

if all ansi codes are removed (PS1='\w $') then there are
no problems at all.



On a related note:

the default /etc/profile sets up these ansi codes by
default for all terminals, I'd suggest that at the bare
minimum these be skipped if the term type is incapable.

I've set mine up as:

if [ "$TERM" == "cygwin" ]; then
	PS1='' #cygwin version with ansi codes
else
	PS1='\w $'
fi
export PS1

and as long as I'm in that file, I just saw the other
patch I put in my copy....

if [ "$SHELL" != "/bin/bash" ]; then
	test -f ./.profile && . ./.profile
	test -f ./.bashrc && . ./.bashrc
fi

this has the advantage for those who run bash of not
sourcing these files twice, as bash does so itself.


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: odd bash wrapping due to ansi codes
  2000-09-17  2:07 odd bash wrapping due to ansi codes Chris Abbey
@ 2000-09-19  7:10 ` Robert Praetorius
  2000-09-19 20:36   ` [patch] " Chris Abbey
  0 siblings, 1 reply; 14+ messages in thread
From: Robert Praetorius @ 2000-09-19  7:10 UTC (permalink / raw)
  To: Chris Abbey; +Cc: cygwin

> '<0x1b>]0;\w<0x07><0x1b>[1m<0x1b>[34m\w<0x1b>[0m $ '

     I've found that bash is happier when I wrap ANSI (or ANSIesque) 
escape and control sequences inside \[ . . . \].  To quote from the 
bash man page:

          \[   begin a sequence of non-printing characters, which
               could be used to embed a terminal control sequence
               into the prompt
          \]   end a sequence of non-printing characters


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch] Re: odd bash wrapping due to ansi codes
  2000-09-19  7:10 ` Robert Praetorius
@ 2000-09-19 20:36   ` Chris Abbey
  2000-09-19 21:23     ` Randall R Schulz
  2000-09-25 18:20     ` DJ Delorie
  0 siblings, 2 replies; 14+ messages in thread
From: Chris Abbey @ 2000-09-19 20:36 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]

At 00:08 9/20/00 +1000, Robert Praetorius wrote:
>      I've found that bash is happier when I wrap ANSI (or ANSIesque)
>escape and control sequences inside \[ . . . \].  To quote from the
>bash man page:
>
>           \[   begin a sequence of non-printing characters, which
>                could be used to embed a terminal control sequence
>                into the prompt
>           \]   end a sequence of non-printing characters


BINGO! With Robert's addition I've cleared up 95% of the problems
I'm seeing with shells. (I actually had to resort to a cmd.exe prompt
today because my office mates were threatening violence)

I've discovered that the default configuration is *far* less susceptible
to these problems due to it's multi line nature and 80 column width.
However I think this can be considered "doing the right thing" and will
make the default configuration a better starting point for those who
tweak the shell to feel more like their other systems.

I've attached the patch as a bz2 because it's got control chars
littered through it. (somewhere between work and home there is
an smtp server that kept crashing on this patch)
patch.bz2
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


[-- Attachment #2: patch.bz2 --]
[-- Type: application/x-bzip2, Size: 240 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch] Re: odd bash wrapping due to ansi codes
  2000-09-19 20:36   ` [patch] " Chris Abbey
@ 2000-09-19 21:23     ` Randall R Schulz
  2000-09-19 22:24       ` Chris Abbey
  2000-09-25 13:42       ` DJ Delorie
  2000-09-25 18:20     ` DJ Delorie
  1 sibling, 2 replies; 14+ messages in thread
From: Randall R Schulz @ 2000-09-19 21:23 UTC (permalink / raw)
  To: Chris Abbey, cygwin

Chris,

Well, I cannot say that I like the new default prompt, but I'm a 
customization freak and tweak everything to my liking, anyway. But 
the thing that gets on my nerves after about 45 seconds is the "neon 
sign store window" effect of all that hiddeous colorization! I had to 
add a few lines to my .vimrc to turn search highlighting and "syntax 
coloring" off. I also added some macros to easily switch the 
colorization mode on and off when I want a glimpse of the colors to 
check for a runaway string.

Anyway, I really wrote to make sure you knew that the BASH behavior 
you're discovering is common to all BASH shells, not just Cygwin. I 
don't know for a fact, but that behavior might actually originate in 
the readline library.

Randall Schulz
Teknowledge Corp.
Palo Alto, CA USA


At 22:35 -0500 9/19/00, Chris Abbey wrote:
>At 00:08 9/20/00 +1000, Robert Praetorius wrote:
>>      I've found that bash is happier when I wrap ANSI (or ANSIesque)
>>escape and control sequences inside \[ . . . \].  To quote from the
>>bash man page:
>>
>>           \[   begin a sequence of non-printing characters, which
>>                could be used to embed a terminal control sequence
>>                into the prompt
>>           \]   end a sequence of non-printing characters
>
>
>BINGO! ... I've cleared up 95% of the problems...
>
>I've discovered that the default configuration is *far* less susceptible
>to these problems due to it's multi line nature and 80 column width.
>However I think this can be considered "doing the right thing" and will
>make the default configuration a better starting point for those who
>tweak the shell to feel more like their other systems.
>
>...




--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch] Re: odd bash wrapping due to ansi codes
  2000-09-19 21:23     ` Randall R Schulz
@ 2000-09-19 22:24       ` Chris Abbey
  2000-09-20  5:58         ` Andreas Eibach
  2000-09-25 13:42       ` DJ Delorie
  1 sibling, 1 reply; 14+ messages in thread
From: Chris Abbey @ 2000-09-19 22:24 UTC (permalink / raw)
  To: Randall R Schulz; +Cc: cygwin

yeah, the default setup is ... well since the person who set it up is
probably on this list I won't go into that.... let's just say my version
is quite different as well. On the other hand, there's a couple guys at
work that LOVE that type of setup... to each their own.

>Anyway, I really wrote to make sure you knew that the BASH behavior you're 
>discovering is common to all BASH shells, not just Cygwin. I don't know 
>for a fact, but that behavior might actually originate in the readline library.

hmm... I *don't* see this on Linux, or AIX and I don't recall it on Solaris
or *BSD; but it's been a while since I was on either of those platforms.

Here's the PS1 string I use on Linux and Cygwin:
'\[\033]0;\w\007\033[1m\033[34m\]\w\[\033[0m\] $ '
to the best of my recollection AIX is the same. (and I'm very embarrassed to
admit that my Linux box already *had* the \[ \] wrappers.)

I just did an experiment in removing the \[ \] wrappers on Linux and it does
not exhibit the same odd wrapping problems that Cygwin did. (it did have a 
minor
problem when the prompt was near the right edge, and the current command flowed
to the next line AND the new prompt wrapped off the right edge, but it was 
a minor
problem and would probably not have been noticed if I wasn't looking (it 
lost one
character in the prompt string))

That linux had this minor improvement to "perfect" handling of my test I'm now
even more convinced this is the right thing to do.

p.s. for the two of you folks that asked for a better explanation of what I was
talking about:

http://pws.bresnanlink.net/~cabbey/broken.png cygwin w/o \[ \] (note that
what's missing is a *lot* of bells when the first broken prompt is printed,
and one or two every time thereafter.)
http://pws.bresnanlink.net/~cabbey/cygnus.png cygwin w/ \[ \] (near perfect)
http://pws.bresnanlink.net/~cabbey/linux.png linux w/ \[ \] (perfect)


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch] Re: odd bash wrapping due to ansi codes
  2000-09-19 22:24       ` Chris Abbey
@ 2000-09-20  5:58         ` Andreas Eibach
  0 siblings, 0 replies; 14+ messages in thread
From: Andreas Eibach @ 2000-09-20  5:58 UTC (permalink / raw)
  To: Randall R Schulz, Chris Abbey; +Cc: cygwin

> http://pws.bresnanlink.net/~cabbey/broken.png cygwin w/o \[ \] (note that
> what's missing is a *lot* of bells when the first broken prompt is
printed,
> and one or two every time thereafter.)

> http://pws.bresnanlink.net/~cabbey/cygnus.png cygwin w/ \[ \] (near
perfect)

That link doesn't work.
The one below does:
http://pws.bresnanlink.net/~cabbey/cygwin.png cygwin w/ \[ \] (near perfect)

Andreas


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch] Re: odd bash wrapping due to ansi codes
  2000-09-19 21:23     ` Randall R Schulz
  2000-09-19 22:24       ` Chris Abbey
@ 2000-09-25 13:42       ` DJ Delorie
  1 sibling, 0 replies; 14+ messages in thread
From: DJ Delorie @ 2000-09-25 13:42 UTC (permalink / raw)
  To: rschulz; +Cc: cabbey, cygwin

> Well, I cannot say that I like the new default prompt,

Changing from the current default to a plain prompt is much easier
than the reverse; the default is intentionally an example of doing a
complex prompt.  Plus, it's *my* preferred prompt ;-)

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch] Re: odd bash wrapping due to ansi codes
  2000-09-19 20:36   ` [patch] " Chris Abbey
  2000-09-19 21:23     ` Randall R Schulz
@ 2000-09-25 18:20     ` DJ Delorie
  2000-10-01  0:43       ` Chris Abbey
  1 sibling, 1 reply; 14+ messages in thread
From: DJ Delorie @ 2000-09-25 18:20 UTC (permalink / raw)
  To: cabbey; +Cc: cygwin

Could you supply a patch to the sources, not the generated profile?
They're in src/winsup/cinstall/desktop.cc

Don't forget the ChangeLog entry!

http://sources.redhat.com/cygwin/cvs.html

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch] Re: odd bash wrapping due to ansi codes
  2000-09-25 18:20     ` DJ Delorie
@ 2000-10-01  0:43       ` Chris Abbey
  2000-10-01  3:34         ` [RE-patch] " Chris Abbey
  0 siblings, 1 reply; 14+ messages in thread
From: Chris Abbey @ 2000-10-01  0:43 UTC (permalink / raw)
  To: DJ Delorie; +Cc: cygwin

sorry for the delay, I've been offline for a week...
Wow, I didn't realize this was generated; here's the first patch
I propose, and the one most likely to be acceptable to all.

~/cyg $ cvs diff -ub src/winsup/cinstall/desktop.cc
Index: src/winsup/cinstall/desktop.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/desktop.cc,v
retrieving revision 2.2
diff -u -b -r2.2 desktop.cc
--- desktop.cc  2000/09/08 00:14:20     2.2
+++ desktop.cc  2000/10/01 07:26:38
@@ -77,8 +77,8 @@
    "done",
    "",
    "export MAKE_MODE=unix",
-  "export PS1='\033]0;\\w\a",
-  "\033[32m\\u@\\h \033[33m\\w\033[0m",
+  "export PS1='\\[\\033]0;\\w\a",
+  "\\033[32m\\]\\u@\\h \\[\\033[33m\\w\\033[0m\\]",
    "$ '",
    "",
    "cd $HOME",


changelog:

2000-10-01  Chris Abbey <chris_abbey@yahoo.com>

         * desktop.cc:  cleaned up PS1: wrapped non-printables in
                        \[ \], used escape sequences for binary chars.

At 21:19 9/25/00 -0400, you wrote:

>Could you supply a patch to the sources, not the generated profile?
>They're in src/winsup/cinstall/desktop.cc
>
>Don't forget the ChangeLog entry!
>
> http://sources.redhat.com/cygwin/cvs.html


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [RE-patch] Re: odd bash wrapping due to ansi codes
  2000-10-01  0:43       ` Chris Abbey
@ 2000-10-01  3:34         ` Chris Abbey
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Abbey @ 2000-10-01  3:34 UTC (permalink / raw)
  To: DJ Delorie; +Cc: cygwin

as yall will notice I missed a binary character in the previous patch,
this one is corrected... not sure why I didn't catch that before....

~/cyg/src/winsup/cinstall $ cvs diff -ub desktop.cc
Index: desktop.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/desktop.cc,v
retrieving revision 2.2
diff -u -b -r2.2 desktop.cc
--- desktop.cc  2000/09/08 00:14:20     2.2
+++ desktop.cc  2000/10/01 10:23:30
@@ -77,8 +77,8 @@
    "done",
    "",
    "export MAKE_MODE=unix",
-  "export PS1='\033]0;\\w\a",
-  "\033[32m\\u@\\h \033[33m\\w\033[0m",
+  "export PS1='\\[\\033]0;\\w\\007",
+  "\\033[32m\\]\\u@\\h \\[\\033[33m\\w\\033[0m\\]",
    "$ '",
    "",
    "cd $HOME",


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: odd bash wrapping due to ansi codes
@ 2000-09-25 17:10 Earnie Boyd
  0 siblings, 0 replies; 14+ messages in thread
From: Earnie Boyd @ 2000-09-25 17:10 UTC (permalink / raw)
  To: Chris Abbey; +Cc: cygwin users

--- Chris Abbey <cabbey@bresnanlink.net> wrote:
> At 06:46 9/19/00 -0700, you wrote:
> >AISI,
> >
> > > if [ "$SHELL" != "/bin/bash" ]; then
> > >      test -f ./.profile && . ./.profile
> > > fi
> >
> >can be deleted from /etc/profile.  You only need
> >
> > > test -f ./.bashrc && . ./.bashrc
> >
> >Cheers,
> 
> what about users of other shells? do not they need ~/.profile as well?
> 

Sorry, Chris, I just received this.

I'm not sure.  Bourne compliant shells are going to read /etc/profile but it
may be a matter of the implementation for the ~/.profile file.  Does anyone on
the list know the answer to Chris' question?

Cheers,

=====
--- < http://earniesystems.safeshopper.com > ---
   Earnie Boyd: < mailto:earnie_boyd@yahoo.com >
            __Cygwin: POSIX on Windows__
Cygwin Newbies: < http://gw32.freeyellow.com/ >
           __Minimalist GNU for Windows__
    Mingw Home: < http://www.mingw.org/ >

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: odd bash wrapping due to ansi codes
@ 2000-09-19  6:46 Earnie Boyd
  0 siblings, 0 replies; 14+ messages in thread
From: Earnie Boyd @ 2000-09-19  6:46 UTC (permalink / raw)
  To: Chris Abbey, cygwin

--- Chris Abbey <cabbey@bresnanlink.net> wrote:
> 
> In which case I'd think the 'fi' element in my changed /etc/profile
> can move up one line:
> 

AISI,

> if [ "$SHELL" != "/bin/bash" ]; then
>      test -f ./.profile && . ./.profile
> fi

can be deleted from /etc/profile.  You only need

> test -f ./.bashrc && . ./.bashrc

Cheers,

=====
--- < http://earniesystems.safeshopper.com > ---
   Earnie Boyd: < mailto:earnie_boyd@yahoo.com >
            __Cygwin: POSIX on Windows__
Cygwin Newbies: < http://gw32.freeyellow.com/ >
           __Minimalist GNU for Windows__
    Mingw Home: < http://www.mingw.org/ >

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: odd bash wrapping due to ansi codes
  2000-09-18  5:40 Earnie Boyd
@ 2000-09-18 22:29 ` Chris Abbey
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Abbey @ 2000-09-18 22:29 UTC (permalink / raw)
  To: cygwin

At 05:40 9/18/00 -0700, Earnie Boyd wrote:
>--- Chris Abbey <cabbey@bresnanlink.net> wrote:
> > if [ "$SHELL" != "/bin/bash" ]; then
> >       test -f ./.profile && . ./.profile
> >       test -f ./.bashrc && . ./.bashrc
> > fi
> >
> > this has the advantage for those who run bash of not
> > sourcing these files twice, as bash does so itself.
>
>No, it doesn't always.  If --login then ./.bashrc is not performed but
>./.profile is, and without --login ./.bashrc is performed but not ./.profile.
>Also, without --login the /etc/profile isn't performed and shouldn't be a
>concern.

ok, my head hurts now. This explains why when I forget that the
cmd shell I'm in didn't start from bash that bash looks wierd when
I start it....

iow in bash.exe:
if (args.contains("--login")) {
     source = {"/etc/profile", "~/.profile"};
} else {
     source = "~/.bashrc";
}

ANYWAY... the circumstance I'm concerned with was the default bash
shell that comes up when the user clicks on that funky little Cygwin
icon on their desktop. So '--login -i' are the arguments; in which
case the pattern is:

/etc/profile sources ~/.profile
/etc/profile sources ~/.bashrc
bash sources ~/.profile

(I guess since I don't have a ~/.bashrc I never noticed it
wasn't being run twice. ;)

In which case I'd think the 'fi' element in my changed /etc/profile
can move up one line:

if [ "$SHELL" != "/bin/bash" ]; then
     test -f ./.profile && . ./.profile
fi
test -f ./.bashrc && . ./.bashrc


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: odd bash wrapping due to ansi codes
@ 2000-09-18  5:40 Earnie Boyd
  2000-09-18 22:29 ` Chris Abbey
  0 siblings, 1 reply; 14+ messages in thread
From: Earnie Boyd @ 2000-09-18  5:40 UTC (permalink / raw)
  To: Chris Abbey, cygwin

--- Chris Abbey <cabbey@bresnanlink.net> wrote:
> 
> I've set mine up as:
> 
> if [ "$TERM" == "cygwin" ]; then
> 	PS1='' #cygwin version with ansi codes
> else
> 	PS1='\w $'
> fi
> export PS1
> 
> and as long as I'm in that file, I just saw the other
> patch I put in my copy....
> 
> if [ "$SHELL" != "/bin/bash" ]; then
> 	test -f ./.profile && . ./.profile
> 	test -f ./.bashrc && . ./.bashrc
> fi
> 
> this has the advantage for those who run bash of not
> sourcing these files twice, as bash does so itself.
> 

No, it doesn't always.  If --login then ./.bashrc is not performed but
./.profile is, and without --login ./.bashrc is performed but not ./.profile. 
Also, without --login the /etc/profile isn't performed and shouldn't be a
concern.

Cheers,

=====
--- < http://earniesystems.safeshopper.com > ---
   Earnie Boyd: < mailto:earnie_boyd@yahoo.com >
            __Cygwin: POSIX on Windows__
Cygwin Newbies: < http://gw32.freeyellow.com/ >
           __Minimalist GNU for Windows__
    Mingw Home: < http://www.mingw.org/ >

__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2000-10-01  3:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-17  2:07 odd bash wrapping due to ansi codes Chris Abbey
2000-09-19  7:10 ` Robert Praetorius
2000-09-19 20:36   ` [patch] " Chris Abbey
2000-09-19 21:23     ` Randall R Schulz
2000-09-19 22:24       ` Chris Abbey
2000-09-20  5:58         ` Andreas Eibach
2000-09-25 13:42       ` DJ Delorie
2000-09-25 18:20     ` DJ Delorie
2000-10-01  0:43       ` Chris Abbey
2000-10-01  3:34         ` [RE-patch] " Chris Abbey
2000-09-18  5:40 Earnie Boyd
2000-09-18 22:29 ` Chris Abbey
2000-09-19  6:46 Earnie Boyd
2000-09-25 17:10 Earnie Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).