sh: Automatically enable -o emacs in interactive shells with terminals.

This makes sh a bit more friendly in single user mode, make buildenv, chroot
and the like, and matches other shells.

The -o emacs can be overridden on the command line or in the ENV file.
This commit is contained in:
Jilles Tjoelker 2010-04-05 14:15:51 +00:00
parent 25f82a3e0b
commit d5f6b530fc
2 changed files with 7 additions and 3 deletions

View File

@ -93,8 +93,11 @@ procargs(int argc, char **argv)
options(1); options(1);
if (*argptr == NULL && minusc == NULL) if (*argptr == NULL && minusc == NULL)
sflag = 1; sflag = 1;
if (iflag == 2 && sflag == 1 && isatty(0) && isatty(1)) if (iflag != 0 && sflag == 1 && isatty(0) && isatty(1)) {
iflag = 1; iflag = 1;
if (Eflag == 2)
Eflag = 1;
}
if (mflag == 2) if (mflag == 2)
mflag = iflag; mflag = iflag;
for (i = 0; i < NOPTS; i++) for (i = 0; i < NOPTS; i++)

View File

@ -32,7 +32,7 @@
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd April 4, 2010 .Dd April 5, 2010
.Dt SH 1 .Dt SH 1
.Os .Os
.Sh NAME .Sh NAME
@ -210,7 +210,8 @@ Enable the built-in
.Xr emacs 1 .Xr emacs 1
command line editor (disables the command line editor (disables the
.Fl V .Fl V
option if it has been set). option if it has been set;
set automatically when interactive on terminals).
.It Fl e Li errexit .It Fl e Li errexit
Exit immediately if any untested command fails in non-interactive mode. Exit immediately if any untested command fails in non-interactive mode.
The exit status of a command is considered to be The exit status of a command is considered to be