Bug 8956

Summary: Sh outputs an extra control character
Product: Busybox Reporter: Matthias Pall Gissurarson <icetritlo>
Component: WebsiteAssignee: unassigned
Status: NEW ---    
Severity: minor CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

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?