summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2021-10-12 22:39:11 +0200
committerDenys Vlasenko2021-10-13 00:09:07 +0200
commit62f1eed1e1916afbff8f9ce3f820626348e8b867 (patch)
treef404ee3cee51b73b80a84c19021464bb54ad0c2c
parentc33bbcb92fc255e4bb058e64874289cdeb0701f9 (diff)
downloadbusybox-62f1eed1e1916afbff8f9ce3f820626348e8b867.zip
busybox-62f1eed1e1916afbff8f9ce3f820626348e8b867.tar.gz
hush: in a comment, document what -i might be doing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c5
-rw-r--r--shell/hush.c29
2 files changed, 28 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 2d3cc8a..1982a24 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -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')
diff --git a/shell/hush.c b/shell/hush.c
index 38d924a..3a17f5b 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -3360,7 +3360,7 @@ static int glob_brace(char *pattern, o_string *o, int n)
* NEXT points past the terminator of the first element, and REST
* points past the final }. We will accumulate result names from
* recursive runs for each brace alternative in the buffer using
- * GLOB_APPEND. */
+ * GLOB_APPEND. */
p = begin + 1;
while (1) {
@@ -10225,7 +10225,7 @@ int hush_main(int argc, char **argv)
cached_getpid = getpid(); /* for tcsetpgrp() during init */
G.root_pid = cached_getpid; /* for $PID (NOMMU can override via -$HEXPID:HEXPPID:...) */
- G.root_ppid = getppid(); /* for $PPID (NOMMU can override) */
+ G.root_ppid = getppid(); /* for $PPID (NOMMU can override) */
/* Deal with HUSH_VERSION */
debug_printf_env("unsetenv '%s'\n", "HUSH_VERSION");
@@ -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;
@@ -11732,7 +11755,7 @@ static int FAST_FUNC builtin_fg_bg(char **argv)
/* TODO: bash prints a string representation
* of job being foregrounded (like "sleep 1 | cat") */
if (argv[0][0] == 'f' && G_saved_tty_pgrp) {
- /* Put the job into the foreground. */
+ /* Put the job into the foreground. */
tcsetpgrp(G_interactive_fd, pi->pgrp);
}