1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

ksh -i: only print newline on EOF if really interactive

Some regression tests have to be run with the -i option, making the
shell behave (mostly) as if it is interactive. This causes ksh to
print a final newline upon EOF (Ctrl+D). This is functional if the
shell is really interactive, i.e. if standard input is on a
terminal and we're not running a shell script: it ensures that a
parent shell's prompt appears on a new line. But for tests like
   ksh -i -c 'testcommands'
or
   ksh -i <<EOF
   testcommands
   EOF
it's a minor annoyance. Adding an explicit 'exit' is an effective
workaround, but we might as well fix it.

src/cmd/ksh93/sh/main.c: exfile(): done:
- If shell is "interactive", only print final newline if standard
  input is on a terminal and we're not running a -c script.
This commit is contained in:
Martijn Dekker 2020-07-20 15:37:39 +01:00
parent bd88cc7f4f
commit b2bdbef561

View file

@ -593,6 +593,7 @@ done:
sh_popcontext(shp,&buff); sh_popcontext(shp,&buff);
if(sh_isstate(SH_INTERACTIVE)) if(sh_isstate(SH_INTERACTIVE))
{ {
if(isatty(0) && !sh_isoption(SH_CFLAG))
sfputc(sfstderr,'\n'); sfputc(sfstderr,'\n');
job_close(shp); job_close(shp);
} }