hush: in a comment, document what -i might be doing

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2021-10-12 22:39:11 +02:00
parent c33bbcb92f
commit 62f1eed1e1
2 changed files with 28 additions and 6 deletions

View File

@ -14657,11 +14657,10 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
}
state2:
state = 3;
if (
if (iflag
#ifndef linux
getuid() == geteuid() && getgid() == getegid() &&
&& getuid() == geteuid() && getgid() == getegid()
#endif
iflag
) {
const char *shinit = lookupvar("ENV");
if (shinit != NULL && *shinit != '\0')

View File

@ -10356,6 +10356,29 @@ int hush_main(int argc, char **argv)
/* Well, we cannot just declare interactiveness,
* we have to have some stuff (ctty, etc) */
/* G_interactive_fd++; */
//There are a few cases where bash -i -c 'SCRIPT'
//has visible effect (differs from bash -c 'SCRIPT'):
//it ignores TERM:
// bash -i -c 'kill $$; echo ALIVE'
// ALIVE
//it resets SIG_INGed HUP to SIG_DFL:
// trap '' hup; bash -i -c 'kill -hup $$; echo ALIVE'
// Hangup [the message is not printed by bash, it's the shell which started it]
//is talkative about jobs and exiting:
// bash -i -c 'sleep 1 & exit'
// [1] 16170
// exit
//includes $ENV file (only if run as "sh"):
// echo last >/tmp/ENV; ENV=/tmp/ENV sh -i -c 'echo HERE'
// last: cannot open /var/log/wtmp: No such file or directory
// HERE
//(under "bash", it's the opposite: it runs $BASH_ENV file only *without* -i).
//
//ash -i -c 'sleep 3; sleep 3', on ^C, drops into a prompt instead of exiting
//(this may be a bug, bash does not do this).
//(ash -i -c 'sleep 3' won't show this, the last command gets auto-"exec"ed)
//
//None of the above feel like useful features people would rely on.
break;
case 's':
G.opt_s = 1;