aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-10-12 22:39:11 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-10-13 00:09:07 +0200
commit62f1eed1e1916afbff8f9ce3f820626348e8b867 (patch)
treef404ee3cee51b73b80a84c19021464bb54ad0c2c
parentc33bbcb92fc255e4bb058e64874289cdeb0701f9 (diff)
downloadbusybox-w32-62f1eed1e1916afbff8f9ce3f820626348e8b867.tar.gz
busybox-w32-62f1eed1e1916afbff8f9ce3f820626348e8b867.tar.bz2
busybox-w32-62f1eed1e1916afbff8f9ce3f820626348e8b867.zip
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 2d3cc8a61..1982a24b7 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14657,11 +14657,10 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
14657 } 14657 }
14658 state2: 14658 state2:
14659 state = 3; 14659 state = 3;
14660 if ( 14660 if (iflag
14661#ifndef linux 14661#ifndef linux
14662 getuid() == geteuid() && getgid() == getegid() && 14662 && getuid() == geteuid() && getgid() == getegid()
14663#endif 14663#endif
14664 iflag
14665 ) { 14664 ) {
14666 const char *shinit = lookupvar("ENV"); 14665 const char *shinit = lookupvar("ENV");
14667 if (shinit != NULL && *shinit != '\0') 14666 if (shinit != NULL && *shinit != '\0')
diff --git a/shell/hush.c b/shell/hush.c
index 38d924a3f..3a17f5bd5 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -3360,7 +3360,7 @@ static int glob_brace(char *pattern, o_string *o, int n)
3360 * NEXT points past the terminator of the first element, and REST 3360 * NEXT points past the terminator of the first element, and REST
3361 * points past the final }. We will accumulate result names from 3361 * points past the final }. We will accumulate result names from
3362 * recursive runs for each brace alternative in the buffer using 3362 * recursive runs for each brace alternative in the buffer using
3363 * GLOB_APPEND. */ 3363 * GLOB_APPEND. */
3364 3364
3365 p = begin + 1; 3365 p = begin + 1;
3366 while (1) { 3366 while (1) {
@@ -10225,7 +10225,7 @@ int hush_main(int argc, char **argv)
10225 10225
10226 cached_getpid = getpid(); /* for tcsetpgrp() during init */ 10226 cached_getpid = getpid(); /* for tcsetpgrp() during init */
10227 G.root_pid = cached_getpid; /* for $PID (NOMMU can override via -$HEXPID:HEXPPID:...) */ 10227 G.root_pid = cached_getpid; /* for $PID (NOMMU can override via -$HEXPID:HEXPPID:...) */
10228 G.root_ppid = getppid(); /* for $PPID (NOMMU can override) */ 10228 G.root_ppid = getppid(); /* for $PPID (NOMMU can override) */
10229 10229
10230 /* Deal with HUSH_VERSION */ 10230 /* Deal with HUSH_VERSION */
10231 debug_printf_env("unsetenv '%s'\n", "HUSH_VERSION"); 10231 debug_printf_env("unsetenv '%s'\n", "HUSH_VERSION");
@@ -10356,6 +10356,29 @@ int hush_main(int argc, char **argv)
10356 /* Well, we cannot just declare interactiveness, 10356 /* Well, we cannot just declare interactiveness,
10357 * we have to have some stuff (ctty, etc) */ 10357 * we have to have some stuff (ctty, etc) */
10358 /* G_interactive_fd++; */ 10358 /* G_interactive_fd++; */
10359//There are a few cases where bash -i -c 'SCRIPT'
10360//has visible effect (differs from bash -c 'SCRIPT'):
10361//it ignores TERM:
10362// bash -i -c 'kill $$; echo ALIVE'
10363// ALIVE
10364//it resets SIG_INGed HUP to SIG_DFL:
10365// trap '' hup; bash -i -c 'kill -hup $$; echo ALIVE'
10366// Hangup [the message is not printed by bash, it's the shell which started it]
10367//is talkative about jobs and exiting:
10368// bash -i -c 'sleep 1 & exit'
10369// [1] 16170
10370// exit
10371//includes $ENV file (only if run as "sh"):
10372// echo last >/tmp/ENV; ENV=/tmp/ENV sh -i -c 'echo HERE'
10373// last: cannot open /var/log/wtmp: No such file or directory
10374// HERE
10375//(under "bash", it's the opposite: it runs $BASH_ENV file only *without* -i).
10376//
10377//ash -i -c 'sleep 3; sleep 3', on ^C, drops into a prompt instead of exiting
10378//(this may be a bug, bash does not do this).
10379//(ash -i -c 'sleep 3' won't show this, the last command gets auto-"exec"ed)
10380//
10381//None of the above feel like useful features people would rely on.
10359 break; 10382 break;
10360 case 's': 10383 case 's':
10361 G.opt_s = 1; 10384 G.opt_s = 1;
@@ -11732,7 +11755,7 @@ static int FAST_FUNC builtin_fg_bg(char **argv)
11732 /* TODO: bash prints a string representation 11755 /* TODO: bash prints a string representation
11733 * of job being foregrounded (like "sleep 1 | cat") */ 11756 * of job being foregrounded (like "sleep 1 | cat") */
11734 if (argv[0][0] == 'f' && G_saved_tty_pgrp) { 11757 if (argv[0][0] == 'f' && G_saved_tty_pgrp) {
11735 /* Put the job into the foreground. */ 11758 /* Put the job into the foreground. */
11736 tcsetpgrp(G_interactive_fd, pi->pgrp); 11759 tcsetpgrp(G_interactive_fd, pi->pgrp);
11737 } 11760 }
11738 11761