sh: Do not read from stdin if an error occurs during -i -c cmd.

Although using -i with -c does not seem very useful, it seems inappropriate
to read commands from the terminal in this case.

Side effect: if the -s -c extension is used and the -s option is turned off
using 'set +s' during the interactive part, the shell now exits after an
error or interrupt. Note that POSIX only specifies -s as option to sh, not
to set.

See also Austin Group issue #718.
This commit is contained in:
Jilles Tjoelker 2013-07-12 15:29:41 +00:00
parent eeeb863ff0
commit fd7d6d8a29
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=253271
2 changed files with 4 additions and 1 deletions

View File

@ -170,8 +170,8 @@ main(int argc, char *argv[])
if (minusc) { if (minusc) {
evalstring(minusc, sflag ? 0 : EV_EXIT); evalstring(minusc, sflag ? 0 : EV_EXIT);
} }
state4:
if (sflag || minusc == NULL) { if (sflag || minusc == NULL) {
state4: /* XXX ??? - why isn't this before the "if" statement */
cmdloop(1); cmdloop(1);
} }
exitshell(exitstatus); exitshell(exitstatus);

View File

@ -0,0 +1,3 @@
# $FreeBSD$
! echo echo bad | $SH -ic 'fi' 2>/dev/null