Bug 8956 - Sh outputs an extra control character
Summary: Sh outputs an extra control character
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Website (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-20 17:31 UTC by Matthias Pall Gissurarson
Modified: 2016-05-28 19:25 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Pall Gissurarson 2016-05-20 17:31:53 UTC
Greetings,

When I run sh with the parameters

exec env ENV='' HISTFILE=/dev/null PROMPT_COMMAND='' PS1=\#\$\  PS2='' PS3='' /bin/sh

instead of getting back the expected "#$ ", I get "#$ [6n" i.e. the control character "^[[6n" is appended to the output. This causes issues when using tramp and sh to edit files on busybox via emacs, since it tries to match the output with "#$ ". When the same is run on other shells (such as bash), the control character is not present.

This bug was discovered in alpine linux version 3.3.3, for which a docker container can be run via "docker run -it --rm --name alpine alpine sh", which will start the busybox shell.
Comment 1 Matthias Pall Gissurarson 2016-05-20 17:41:04 UTC
The bug is also reproducible in the busybox docker image,
runnable with "docker run -it --name busybox --rm busybox sh"
Comment 2 Matthias Pall Gissurarson 2016-05-27 14:11:03 UTC
So apparently this is caused by EDITING_ASK_TERMINAL
Comment 3 Denys Vlasenko 2016-05-28 19:25:02 UTC
(In reply to Matthias Pall Gissurarson from comment #2)
> So apparently this is caused by EDITING_ASK_TERMINAL

Yes. But sh (to be more precise, lineedit.c code) uses that _only_ if run on a tty.
Are you scraping tty output? Why?