Ticket #2027 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

ghc -e sometimes spills control characters into its output

Reported by: int-e Owned by: igloo
Priority: normal Milestone: 6.8.3
Component: GHCi Version: 6.8.2
Keywords: Cc:
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: Difficulty: Easy (less than 1 hour)
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The behaviour depends on the TERM variable. For example,

# TERM=xterm ghc -e 'return ()' | od -a
0000000 esc   [   ?   1   0   3   4   h
0000010

Workaround: unset the TERM variable.

Analysis: Those control characters are emitted by libreadline on initialisation. They enable the terminal's meta mode.

Attachments

readline.patch Download (49.9 KB) - added by int-e 5 years ago.
proposed fix: Only initialise libreadline if ghc(i) is used interactively from a terminal.

Change History

Changed 5 years ago by int-e

proposed fix: Only initialise libreadline if ghc(i) is used interactively from a terminal.

follow-up: ↓ 2   Changed 5 years ago by duncan

I get this behavior with runghc too. It adds some control character to the end of the output. This makes it unusable in many scripting applications and breaks some testsuite tests. Again, setting TERM=vt100 or similar rather than "xterm" fixes it.

So when verifying the fix, test with runghc as well as ghc -e.

in reply to: ↑ 1   Changed 5 years ago by int-e

Replying to duncan:

I get this behavior with runghc too. It adds some control character to the end of the output. This makes it unusable in many scripting applications and breaks some testsuite tests. Again, setting TERM=vt100 or similar rather than "xterm" fixes it.

Good point. I tried that with my patch and it fixes that case as well, even when input is from a terminal.

  Changed 5 years ago by igloo

  • owner set to igloo
  • milestone set to 6.8.3

Testsuite tests shouldn't be failing as we do

os.environ['TERM'] = 'vt100'

in driver/runtests.py.

  Changed 5 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Thanks for the report & patch! I've applied it to the HEAD and 6.8 branch.

  Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

  Changed 4 years ago by simonmar

  • difficulty changed from Easy (1 hr) to Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.