[SERVER-6990] Clearing the screen in Terminal.app causes prompt to disappear Created: 10/Sep/12  Updated: 10/Dec/14  Resolved: 20/May/13

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.2.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Richard Kreuter (Inactive) Assignee: Tad Marshall
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File test.sh    
Operating System: OS X
Participants:

 Description   

Clearing the screen with ^L inside Terminal.app on the Mac doesn't re-render the prompt.

To reproduce: press Control-L.

Anecdotally, setting a custom prompt to ">>> " and pressing ^L has the same effect.



 Comments   
Comment by Tad Marshall [ 20/May/13 ]

I filed a bug with Apple:
https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/66/wo/cfeS4BQsv0Nh4h4tFMk9eg/9.66

Comment by Tad Marshall [ 20/May/13 ]

This is a bug in Terminal.app and there is no reasonable way to work around it.

The escape sequence ESC [ J is "Erase in Display" and it is supposed to clear the screen from the current cursor position to the end of the screen (when issued without a numeric parameter, or with 0).

This works fine in Terminal.app on any line other than the first line. On the first line, it clears the entire screen.

The attached bash script "test.sh" demonstrates the bug. This script works fine in every VT100 emulator I tried with the exception of the Mac's Terminal.app.

#!/bin/bash                                                                                                                                                                     
line=5
while [ $line -gt 0 ]
do
    echo -en "\033[H\033[Jline 1\nline 2\nline 3\nline 4\nline 5\nline 6\nline 7"
    echo -en "\033[${line};7H <-= The cursor is on line ${line}: about to erase to end of screen (\033[1mESC [ J\033[0m) ..."
    sleep 3
    echo -e "\033[J\n\n\n\nThe message \"The cursor is on line ${line}\" should still be visible"
    sleep 3
    let "line-=1"
done

In xterm on the Mac, the final screen looks like this:

line 1 <-= The cursor is on line 1: about to erase to end of screen (ESC [ J) ...
 
 
 
The message "The cursor is on line 1" should still be visible

In Terminal.app on the Mac, the final screen looks like this:

 
 
 
 
The message "The cursor is on line 1" should still be visible

Tested on Terminal.app in 10.7.5 and 10.8 – fails in both.

Comment by Tad Marshall [ 20/May/13 ]

bash shell script to demonstrate bug in Terminal.app

Comment by Tad Marshall [ 10/Sep/12 ]

xterm on the Mac works fine. On Ubuntu 12.04, I tried Gnome Terminal, xterm, aterm, rxvt and yakuake and all worked fine. Something is not-the-same in the default Mac OS Terminal program.

More odd behavior on this terminal:
1) type "cls" and return; the screen clears and the prompt is displayed;
2) type a character at this new prompt and then hit backspace (labeled "delete" on my Mac keyboard); the prompt is erased.

Generated at Thu Feb 08 03:13:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.