bug in command line handler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

bug in command line handler

K K Subbu
All,

I found an annoying bug with Pharo's eval command line handler. When it
encounters a syntax error, the foreground color is set to red while
printing error message, but not restored after (see attachment). I have
to reset it every time using "echo -e \e[0m" :-(.

I found
----
STCommandLineHandler>>#printCompilerWarning: aSyntaxErrorNotification
...
"print the marker under the error line"
      (lineNumber == errorLine) ifTrue: [
                        stderr red
                                nextPutAll:( '_^_' padLeftTo: position - start + maxLineNumberSize + 4);
                                lf ]]
----
The above code will leave the red color if the error happens on the last
line (as in eval handler), then the color is never restored. Can someone
confirm if this is indeed what is happening? I will file a case and post
a fix, if so.

I also found VTermOutputDriver uses incorrect ANSI color codes (e.g.
white is 37 instead of 97). If the current terminal bg color happens to
be "stderr white", then the error text is unreadable.

Regards .. Subbu

Screenshot from 2017-05-19 15-26-22.png (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: bug in command line handler

Damien Pollet
I wouldn't want to sound sarcastic, but I'm not sure there is such a concept as "correct" in the context of ANSI escape sequences.
Still, according to the legends, 97 is supposed to be high intensity white (for some subset of existing implementations).

On 19 May 2017 at 12:52, K K Subbu <[hidden email]> wrote:
All,

I found an annoying bug with Pharo's eval command line handler. When it encounters a syntax error, the foreground color is set to red while printing error message, but not restored after (see attachment). I have to reset it every time using "echo -e \e[0m" :-(.

I found
----
STCommandLineHandler>>#printCompilerWarning: aSyntaxErrorNotification
...
"print the marker under the error line"
     (lineNumber == errorLine) ifTrue: [
                        stderr red
                                nextPutAll:( '_^_' padLeftTo: position - start + maxLineNumberSize + 4);
                                lf ]]
----
The above code will leave the red color if the error happens on the last line (as in eval handler), then the color is never restored. Can someone confirm if this is indeed what is happening? I will file a case and post a fix, if so.

I also found VTermOutputDriver uses incorrect ANSI color codes (e.g. white is 37 instead of 97). If the current terminal bg color happens to be "stderr white", then the error text is unreadable.

Regards .. Subbu



--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet
Reply | Threaded
Open this post in threaded view
|

Re: bug in command line handler

K K Subbu
On Friday 19 May 2017 05:40 PM, Damien Pollet wrote:
> I wouldn't want to sound sarcastic, but I'm not sure there is such a
> concept as "correct" in the context of ANSI escape sequences.
> Still, according to the legends, 97 is supposed to be high intensity
> white (for some subset of existing implementations).

;-). My context was command line usage in linux terminals.

Anyway, attached is a patch for the annoying bug which fixed the problem
for me. I would appreciate if anyone else using the command line can
confirm if the patch works for them. E.g.

~~~~
$ ./pharo Pharo.image eval 'ProtoObject methodDict size\;^MProtoObject
methodDict keys'
Syntax Error on line 1: 'Variable or expression expected'
=========================================================
1: ProtoObject methodDict size\;
                               _^_
2: ProtoObject methodDict keys
$ ./pharo Pharo.image eval 'ProtoObject methodDict size.^MProtoObject
methodDict keys;'
Syntax Error on line 2: 'Message expected'
==========================================
1: ProtoObject methodDict size.
2: ProtoObject methodDict keys;
                               _^_
$
~~~~

Thanks .. Subbu



resetcolor.cs (1K) Download Attachment