From d5b5c2fa151d318fa96778d5871e23ede312e5fa Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 8 Jan 2017 15:46:04 +0100 Subject: hush: support %%, %+ and % jobspec (meaning "current job") function old new delta parse_jobspec 83 133 +50 builtin_wait 278 283 +5 Signed-off-by: Denys Vlasenko --- shell/hush.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index a56d3b280..58132ef17 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -347,7 +347,7 @@ #define ERR_PTR ((void*)(long)1) -#define JOB_STATUS_FORMAT "[%d] %-22s %.40s\n" +#define JOB_STATUS_FORMAT "[%u] %-22s %.40s\n" #define _SPECIAL_VARS_STR "_*@$!?#" #define SPECIAL_VARS_STR ("_*@$!?#" + 1) @@ -563,7 +563,7 @@ struct pipe { int alive_cmds; /* number of commands running (not exited) */ int stopped_cmds; /* number of commands alive, but stopped */ #if ENABLE_HUSH_JOB - int jobid; /* job number */ + unsigned jobid; /* job number */ pid_t pgrp; /* process group ID for the job */ char *cmdtext; /* name of job */ #endif @@ -740,7 +740,7 @@ struct globals { #endif #if ENABLE_HUSH_JOB int run_list_level; - int last_jobid; + unsigned last_jobid; pid_t saved_tty_pgrp; struct pipe *job_list; # define G_saved_tty_pgrp (G.saved_tty_pgrp) @@ -7043,7 +7043,7 @@ static void insert_bg_job(struct pipe *pi) job->cmdtext = xstrdup(get_cmdtext(pi)); if (G_interactive_fd) - printf("[%d] %d %s\n", job->jobid, job->cmds[0].pid, job->cmdtext); + printf("[%u] %u %s\n", job->jobid, (unsigned)job->cmds[0].pid, job->cmdtext); G.last_jobid = job->jobid; } @@ -9264,11 +9264,21 @@ static int FAST_FUNC builtin_type(char **argv) static struct pipe *parse_jobspec(const char *str) { struct pipe *pi; - int jobnum; + unsigned jobnum; - if (sscanf(str, "%%%d", &jobnum) != 1) { - bb_error_msg("bad argument '%s'", str); - return NULL; + if (sscanf(str, "%%%u", &jobnum) != 1) { + if (str[0] != '%' + || (str[1] != '%' && str[1] != '+' && str[1] != '\0') + ) { + bb_error_msg("bad argument '%s'", str); + return NULL; + } + /* It is "%%", "%+" or "%" - current job */ + jobnum = G.last_jobid; + if (jobnum == 0) { + bb_error_msg("no current job"); + return NULL; + } } for (pi = G.job_list; pi; pi = pi->next) { if (pi->jobid == jobnum) { @@ -9622,13 +9632,15 @@ static int FAST_FUNC builtin_wait(char **argv) #if ENABLE_HUSH_JOB if (argv[0][0] == '%') { struct pipe *wait_pipe; + ret = 127; /* bash compat for bad jobspecs */ wait_pipe = parse_jobspec(*argv); if (wait_pipe) { ret = job_exited_or_stopped(wait_pipe); if (ret < 0) ret = wait_for_child_or_signal(wait_pipe, 0); - continue; } + /* else: parse_jobspec() already emitted error msg */ + continue; } #endif /* mimic bash message */ -- cgit v1.2.3-55-g6feb From 1125d7d6801940a5218b74c8fd46f1eaa2e4de39 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 8 Jan 2017 17:19:38 +0100 Subject: hush: kill builtin and kill %jobspec support Also made it and printf, type and wait builtins optional. function old new delta builtin_kill - 323 +323 bltins1 336 348 +12 builtin_type 114 116 +2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 337/0) Total: 337 bytes Signed-off-by: Denys Vlasenko --- coreutils/Kbuild.src | 5 +- procps/Kbuild.src | 2 + procps/kill.c | 4 +- shell/hush.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 138 insertions(+), 7 deletions(-) (limited to 'shell') diff --git a/coreutils/Kbuild.src b/coreutils/Kbuild.src index d9a448781..9ac6b9e78 100644 --- a/coreutils/Kbuild.src +++ b/coreutils/Kbuild.src @@ -15,11 +15,14 @@ lib-$(CONFIG_LESS) += cat.o # less too lib-$(CONFIG_CRONTAB) += cat.o # crontab -l lib-$(CONFIG_ADDUSER) += chown.o # used by adduser lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser +lib-$(CONFIG_FTPD) += ls.o # used by ftpd + lib-$(CONFIG_ASH) += echo.o # used by ash lib-$(CONFIG_SH_IS_ASH) += echo.o # used by ash lib-$(CONFIG_BASH_IS_ASH) += echo.o # used by ash lib-$(CONFIG_HUSH) += echo.o # used by hush lib-$(CONFIG_SH_IS_HUSH) += echo.o # used by hush lib-$(CONFIG_BASH_IS_HUSH) += echo.o # used by hush -lib-$(CONFIG_FTPD) += ls.o # used by ftpd + lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o +lib-$(CONFIG_HUSH_PRINTF) += printf.o diff --git a/procps/Kbuild.src b/procps/Kbuild.src index e7adc7340..82f37f0df 100644 --- a/procps/Kbuild.src +++ b/procps/Kbuild.src @@ -11,3 +11,5 @@ INSERT lib-$(CONFIG_ASH) += kill.o # used for built-in kill by ash lib-$(CONFIG_SH_IS_ASH) += kill.o # used for built-in kill by ash lib-$(CONFIG_BASH_IS_ASH) += kill.o # used for built-in kill by ash + +lib-$(CONFIG_HUSH_KILL) += kill.o # used for built-in kill by hush diff --git a/procps/kill.c b/procps/kill.c index 36cd22f37..579c8e53c 100644 --- a/procps/kill.c +++ b/procps/kill.c @@ -285,8 +285,8 @@ int kill_main(int argc UNUSED_PARAM, char **argv) /* Looks like they want to do a kill. Do that */ while (arg) { -#if ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH \ - || ENABLE_HUSH || ENABLE_SH_IS_HUSH || ENABLE_BASH_IS_HUSH +#if ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH \ + || ENABLE_HUSH_KILL /* * We need to support shell's "hack formats" of * " -PRGP_ID" (yes, with a leading space) diff --git a/shell/hush.c b/shell/hush.c index 58132ef17..9aafb4d25 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -44,12 +44,12 @@ * special variables (done: PWD, PPID, RANDOM) * tilde expansion * aliases - * kill %jobspec * follow IFS rules more precisely, including update semantics * builtins mandated by standards we don't support: * [un]alias, command, fc, getopts, newgrp, readonly, times * make complex ${var%...} constructs support optional * make here documents optional + * make trap, read, ulimit builtins optional * * Bash compat TODO: * redirection of stdout+stderr: &> and >& @@ -117,6 +117,34 @@ //config: help //config: Enable help builtin in hush. Code size + ~1 kbyte. //config: +//config:config HUSH_PRINTF +//config: bool "printf builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable printf builtin in hush. +//config: +//config:config HUSH_KILL +//config: bool "kill builtin (for kill %jobspec)" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable kill builtin in hush. +//config: +//config:config HUSH_WAIT +//config: bool "wait builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable wait builtin in hush. +//config: +//config:config HUSH_TYPE +//config: bool "type builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable type builtin in hush. +//config: //config:config HUSH_INTERACTIVE //config: bool "Interactive mode" //config: default y @@ -860,7 +888,7 @@ static int builtin_local(char **argv) FAST_FUNC; #if HUSH_DEBUG static int builtin_memleak(char **argv) FAST_FUNC; #endif -#if ENABLE_PRINTF +#if ENABLE_HUSH_PRINTF static int builtin_printf(char **argv) FAST_FUNC; #endif static int builtin_pwd(char **argv) FAST_FUNC; @@ -870,11 +898,18 @@ static int builtin_shift(char **argv) FAST_FUNC; static int builtin_source(char **argv) FAST_FUNC; static int builtin_test(char **argv) FAST_FUNC; static int builtin_trap(char **argv) FAST_FUNC; +#if ENABLE_HUSH_TYPE static int builtin_type(char **argv) FAST_FUNC; +#endif static int builtin_true(char **argv) FAST_FUNC; static int builtin_umask(char **argv) FAST_FUNC; static int builtin_unset(char **argv) FAST_FUNC; +#if ENABLE_HUSH_KILL +static int builtin_kill(char **argv) FAST_FUNC; +#endif +#if ENABLE_HUSH_WAIT static int builtin_wait(char **argv) FAST_FUNC; +#endif #if ENABLE_HUSH_LOOPS static int builtin_break(char **argv) FAST_FUNC; static int builtin_continue(char **argv) FAST_FUNC; @@ -929,6 +964,9 @@ static const struct built_in_command bltins1[] = { #if ENABLE_HUSH_JOB BLTIN("jobs" , builtin_jobs , "List jobs"), #endif +#if ENABLE_HUSH_KILL + BLTIN("kill" , builtin_kill , "Send signals to processes"), +#endif #if ENABLE_HUSH_LOCAL BLTIN("local" , builtin_local , "Set local variables"), #endif @@ -946,18 +984,22 @@ static const struct built_in_command bltins1[] = { #endif BLTIN("trap" , builtin_trap , "Trap signals"), BLTIN("true" , builtin_true , NULL), +#if ENABLE_HUSH_TYPE BLTIN("type" , builtin_type , "Show command type"), +#endif BLTIN("ulimit" , shell_builtin_ulimit , "Control resource limits"), BLTIN("umask" , builtin_umask , "Set file creation mask"), BLTIN("unset" , builtin_unset , "Unset variables"), +#if ENABLE_HUSH_WAIT BLTIN("wait" , builtin_wait , "Wait for process"), +#endif }; /* For now, echo and test are unconditionally enabled. * Maybe make it configurable? */ static const struct built_in_command bltins2[] = { BLTIN("[" , builtin_test , NULL), BLTIN("echo" , builtin_echo , NULL), -#if ENABLE_PRINTF +#if ENABLE_HUSH_PRINTF BLTIN("printf" , builtin_printf , NULL), #endif BLTIN("pwd" , builtin_pwd , NULL), @@ -8689,7 +8731,7 @@ static int FAST_FUNC builtin_echo(char **argv) return run_applet_main(argv, echo_main); } -#if ENABLE_PRINTF +#if ENABLE_HUSH_PRINTF static int FAST_FUNC builtin_printf(char **argv) { return run_applet_main(argv, printf_main); @@ -9227,6 +9269,7 @@ static int FAST_FUNC builtin_trap(char **argv) goto process_sig_list; } +#if ENABLE_HUSH_TYPE /* http://www.opengroup.org/onlinepubs/9699919799/utilities/type.html */ static int FAST_FUNC builtin_type(char **argv) { @@ -9259,6 +9302,7 @@ static int FAST_FUNC builtin_type(char **argv) return ret; } +#endif #if ENABLE_HUSH_JOB static struct pipe *parse_jobspec(const char *str) @@ -9526,6 +9570,87 @@ static int FAST_FUNC builtin_umask(char **argv) return !rc; /* rc != 0 - success */ } +#if ENABLE_HUSH_KILL +static int FAST_FUNC builtin_kill(char **argv) +{ + int ret = 0; + + argv = skip_dash_dash(argv); + if (argv[0] && strcmp(argv[0], "-l") != 0) { + int i = 0; + + do { + struct pipe *pi; + char *dst; + int j, n; + + if (argv[i][0] != '%') + continue; + /* + * "kill %N" - job kill + * Converting to pgrp / pid kill + */ + pi = parse_jobspec(argv[i]); + if (!pi) { + /* Eat bad jobspec */ + j = i; + do { + j++; + argv[j - 1] = argv[j]; + } while (argv[j]); + ret = 1; + i--; + continue; + } + /* + * In jobs started under job control, we signal + * entire process group by kill -PGRP_ID. + * This happens, f.e., in interactive shell. + * + * Otherwise, we signal each child via + * kill PID1 PID2 PID3. + * Testcases: + * sh -c 'sleep 1|sleep 1 & kill %1' + * sh -c 'true|sleep 2 & sleep 1; kill %1' + * sh -c 'true|sleep 1 & sleep 2; kill %1' + */ + n = pi->num_cmds; + if (ENABLE_HUSH_JOB && G_interactive_fd) + n = 1; + dst = alloca(n * sizeof(int)*4); + argv[i] = dst; +#if ENABLE_HUSH_JOB + if (G_interactive_fd) + dst += sprintf(dst, " -%u", (int)pi->pgrp); + else +#endif + for (j = 0; j < n; j++) { + struct command *cmd = &pi->cmds[j]; + /* Skip exited members of the job */ + if (cmd->pid == 0) + continue; + /* + * kill_main has matching code to expect + * leading space. Needed to not confuse + * negative pids with "kill -SIGNAL_NO" syntax + */ + dst += sprintf(dst, " %u", (int)cmd->pid); + } + *dst = '\0'; + } while (argv[++i]); + } + + if (argv[0] || ret == 0) { + argv--; + argv[0] = (char*)"kill"; /* why? think about "kill -- PID" */ + /* kill_main also handles "killall" etc, so it does look at argv[0]! */ + ret = run_applet_main(argv, kill_main); + } + return ret; +} +#endif + +#if ENABLE_HUSH_WAIT /* http://www.opengroup.org/onlinepubs/9699919799/utilities/wait.html */ #if !ENABLE_HUSH_JOB # define wait_for_child_or_signal(pipe,pid) wait_for_child_or_signal(pid) @@ -9686,6 +9811,7 @@ static int FAST_FUNC builtin_wait(char **argv) return ret; } +#endif #if ENABLE_HUSH_LOOPS || ENABLE_HUSH_FUNCTIONS static unsigned parse_numeric_argv1(char **argv, unsigned def, unsigned def_min) -- cgit v1.2.3-55-g6feb From 7a85c60e7e370d0bc171bd10043c1eb7c20ab913 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 8 Jan 2017 17:40:18 +0100 Subject: hush: make read and trap builtins optional Signed-off-by: Denys Vlasenko --- shell/hush.c | 189 +++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 118 insertions(+), 71 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index 9aafb4d25..e6e8c1baf 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -49,7 +49,6 @@ * [un]alias, command, fc, getopts, newgrp, readonly, times * make complex ${var%...} constructs support optional * make here documents optional - * make trap, read, ulimit builtins optional * * Bash compat TODO: * redirection of stdout+stderr: &> and >& @@ -110,41 +109,6 @@ //config: help //config: Enable {abc,def} extension. //config: -//config:config HUSH_HELP -//config: bool "help builtin" -//config: default y -//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable help builtin in hush. Code size + ~1 kbyte. -//config: -//config:config HUSH_PRINTF -//config: bool "printf builtin" -//config: default y -//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable printf builtin in hush. -//config: -//config:config HUSH_KILL -//config: bool "kill builtin (for kill %jobspec)" -//config: default y -//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable kill builtin in hush. -//config: -//config:config HUSH_WAIT -//config: bool "wait builtin" -//config: default y -//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable wait builtin in hush. -//config: -//config:config HUSH_TYPE -//config: bool "type builtin" -//config: default y -//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable type builtin in hush. -//config: //config:config HUSH_INTERACTIVE //config: bool "Interactive mode" //config: default y @@ -209,7 +173,7 @@ //config: Enable support for shell functions in hush. +800 bytes. //config: //config:config HUSH_LOCAL -//config: bool "Support local builtin" +//config: bool "local builtin" //config: default y //config: depends on HUSH_FUNCTIONS //config: help @@ -238,6 +202,62 @@ //config: This instructs hush to print commands before execution. //config: Adds ~300 bytes. //config: +//config:config HUSH_HELP +//config: bool "help builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable help builtin in hush. Code size + ~1 kbyte. +//config: +//config:config HUSH_PRINTF +//config: bool "printf builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable printf builtin in hush. +//config: +//config:config HUSH_KILL +//config: bool "kill builtin (for kill %jobspec)" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable kill builtin in hush. +//config: +//config:config HUSH_WAIT +//config: bool "wait builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable wait builtin in hush. +//config: +//config:config HUSH_TRAP +//config: bool "trap builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable trap builtin in hush. +//config: +//config:config HUSH_ULIMIT +//config: bool "ulimit builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable ulimit builtin in hush. +//config: +//config:config HUSH_TYPE +//config: bool "type builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable type builtin in hush. +//config: +//config:config HUSH_READ +//config: bool "read builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable read builtin in hush. +//config: //config:config MSH //config: bool "msh (deprecated: aliased to hush)" //config: default n @@ -842,7 +862,12 @@ struct globals { #else # define G_fatal_sig_mask 0 #endif +#if ENABLE_HUSH_TRAP char **traps; /* char *traps[NSIG] */ +# define G_traps G.traps +#else +# define G_traps ((char**)NULL) +#endif sigset_t pending_set; #if HUSH_DEBUG unsigned long memleak_value; @@ -892,12 +917,16 @@ static int builtin_memleak(char **argv) FAST_FUNC; static int builtin_printf(char **argv) FAST_FUNC; #endif static int builtin_pwd(char **argv) FAST_FUNC; +#if ENABLE_HUSH_READ static int builtin_read(char **argv) FAST_FUNC; +#endif static int builtin_set(char **argv) FAST_FUNC; static int builtin_shift(char **argv) FAST_FUNC; static int builtin_source(char **argv) FAST_FUNC; static int builtin_test(char **argv) FAST_FUNC; +#if ENABLE_HUSH_TRAP static int builtin_trap(char **argv) FAST_FUNC; +#endif #if ENABLE_HUSH_TYPE static int builtin_type(char **argv) FAST_FUNC; #endif @@ -973,7 +1002,9 @@ static const struct built_in_command bltins1[] = { #if HUSH_DEBUG BLTIN("memleak" , builtin_memleak , NULL), #endif +#if ENABLE_HUSH_READ BLTIN("read" , builtin_read , "Input into variable"), +#endif #if ENABLE_HUSH_FUNCTIONS BLTIN("return" , builtin_return , "Return from a function"), #endif @@ -982,12 +1013,16 @@ static const struct built_in_command bltins1[] = { #if ENABLE_HUSH_BASH_COMPAT BLTIN("source" , builtin_source , "Run commands in a file"), #endif +#if ENABLE_HUSH_TRAP BLTIN("trap" , builtin_trap , "Trap signals"), +#endif BLTIN("true" , builtin_true , NULL), #if ENABLE_HUSH_TYPE BLTIN("type" , builtin_type , "Show command type"), #endif +#if ENABLE_HUSH_ULIMIT BLTIN("ulimit" , shell_builtin_ulimit , "Control resource limits"), +#endif BLTIN("umask" , builtin_umask , "Set file creation mask"), BLTIN("unset" , builtin_unset , "Unset variables"), #if ENABLE_HUSH_WAIT @@ -1712,13 +1747,13 @@ static void hush_exit(int exitcode) #endif fflush_all(); - if (G.exiting <= 0 && G.traps && G.traps[0] && G.traps[0][0]) { + if (G.exiting <= 0 && G_traps && G_traps[0] && G_traps[0][0]) { char *argv[3]; /* argv[0] is unused */ - argv[1] = G.traps[0]; + argv[1] = G_traps[0]; argv[2] = NULL; G.exiting = 1; /* prevent EXIT trap recursion */ - /* Note: G.traps[0] is not cleared! + /* Note: G_traps[0] is not cleared! * "trap" will still show it, if executed * in the handler */ builtin_eval(argv); @@ -1769,14 +1804,14 @@ static int check_and_run_traps(void) } while (sig < NSIG); break; got_sig: - if (G.traps && G.traps[sig]) { + if (G_traps && G_traps[sig]) { debug_printf_exec("%s: sig:%d handler:'%s'\n", __func__, sig, G.traps[sig]); - if (G.traps[sig][0]) { + if (G_traps[sig][0]) { /* We have user-defined handler */ smalluint save_rcode; char *argv[3]; /* argv[0] is unused */ - argv[1] = G.traps[sig]; + argv[1] = G_traps[sig]; argv[2] = NULL; save_rcode = G.last_exitcode; builtin_eval(argv); @@ -5924,13 +5959,15 @@ static void switch_off_special_sigs(unsigned mask) sig++; if (!(mask & 1)) continue; - if (G.traps) { - if (G.traps[sig] && !G.traps[sig][0]) +#if ENABLE_HUSH_TRAP + if (G_traps) { + if (G_traps[sig] && !G_traps[sig][0]) /* trap is '', has to remain SIG_IGN */ continue; - free(G.traps[sig]); - G.traps[sig] = NULL; + free(G_traps[sig]); + G_traps[sig] = NULL; } +#endif /* We are here only if no trap or trap was not '' */ install_sighandler(sig, SIG_DFL); } @@ -5947,7 +5984,7 @@ static void reset_traps_to_defaults(void) /* This function is always called in a child shell * after fork (not vfork, NOMMU doesn't use this function). */ - unsigned sig; + IF_HUSH_TRAP(unsigned sig;) unsigned mask; /* Child shells are not interactive. @@ -5956,35 +5993,37 @@ static void reset_traps_to_defaults(void) * Same goes for SIGTERM, SIGHUP, SIGINT. */ mask = (G.special_sig_mask & SPECIAL_INTERACTIVE_SIGS) | G_fatal_sig_mask; - if (!G.traps && !mask) + if (!G_traps && !mask) return; /* already no traps and no special sigs */ /* Switch off special sigs */ switch_off_special_sigs(mask); -#if ENABLE_HUSH_JOB +# if ENABLE_HUSH_JOB G_fatal_sig_mask = 0; -#endif +# endif G.special_sig_mask &= ~SPECIAL_INTERACTIVE_SIGS; /* SIGQUIT,SIGCHLD and maybe SPECIAL_JOBSTOP_SIGS * remain set in G.special_sig_mask */ - if (!G.traps) +# if ENABLE_HUSH_TRAP + if (!G_traps) return; /* Reset all sigs to default except ones with empty traps */ for (sig = 0; sig < NSIG; sig++) { - if (!G.traps[sig]) + if (!G_traps[sig]) continue; /* no trap: nothing to do */ - if (!G.traps[sig][0]) + if (!G_traps[sig][0]) continue; /* empty trap: has to remain SIG_IGN */ /* sig has non-empty trap, reset it: */ - free(G.traps[sig]); - G.traps[sig] = NULL; + free(G_traps[sig]); + G_traps[sig] = NULL; /* There is no signal for trap 0 (EXIT) */ if (sig == 0) continue; install_sighandler(sig, pick_sighandler(sig)); } +# endif } #else /* !BB_MMU */ @@ -6024,10 +6063,10 @@ static void re_execute_shell(char ***to_free, const char *s, cnt++; empty_trap_mask = 0; - if (G.traps) { + if (G_traps) { int sig; for (sig = 1; sig < NSIG; sig++) { - if (G.traps[sig] && !G.traps[sig][0]) + if (G_traps[sig] && !G_traps[sig][0]) empty_trap_mask |= 1LL << sig; } } @@ -6220,6 +6259,7 @@ static FILE *generate_stream_from_string(const char *s, pid_t *pid_p) xmove_fd(channel[1], 1); /* Prevent it from trying to handle ctrl-z etc */ IF_HUSH_JOB(G.run_list_level = 1;) +# if ENABLE_HUSH_TRAP /* Awful hack for `trap` or $(trap). * * http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html @@ -6263,6 +6303,7 @@ static FILE *generate_stream_from_string(const char *s, pid_t *pid_p) fflush_all(); /* important */ _exit(0); } +# endif # if BB_MMU reset_traps_to_defaults(); parse_and_run_string(s); @@ -8160,10 +8201,12 @@ static void install_sighandlers(unsigned mask) if (old_handler == SIG_IGN) { /* oops... restore back to IGN, and record this fact */ install_sighandler(sig, old_handler); - if (!G.traps) - G.traps = xzalloc(sizeof(G.traps[0]) * NSIG); - free(G.traps[sig]); - G.traps[sig] = xzalloc(1); /* == xstrdup(""); */ +#if ENABLE_HUSH_TRAP + if (!G_traps) + G_traps = xzalloc(sizeof(G_traps[0]) * NSIG); + free(G_traps[sig]); + G_traps[sig] = xzalloc(1); /* == xstrdup(""); */ +#endif } } } @@ -8464,10 +8507,10 @@ int hush_main(int argc, char **argv) if (empty_trap_mask != 0) { int sig; install_special_sighandlers(); - G.traps = xzalloc(sizeof(G.traps[0]) * NSIG); + G_traps = xzalloc(sizeof(G_traps[0]) * NSIG); for (sig = 1; sig < NSIG; sig++) { if (empty_trap_mask & (1LL << sig)) { - G.traps[sig] = xzalloc(1); /* == xstrdup(""); */ + G_traps[sig] = xzalloc(1); /* == xstrdup(""); */ install_sighandler(sig, SIG_IGN); } } @@ -9114,6 +9157,7 @@ static int FAST_FUNC builtin_shift(char **argv) return EXIT_FAILURE; } +#if ENABLE_HUSH_READ /* Interruptibility of read builtin in bash * (tested on bash-4.2.8 by sending signals (not by ^C)): * @@ -9178,23 +9222,25 @@ static int FAST_FUNC builtin_read(char **argv) return (uintptr_t)r; } +#endif +#if ENABLE_HUSH_TRAP static int FAST_FUNC builtin_trap(char **argv) { int sig; char *new_cmd; - if (!G.traps) - G.traps = xzalloc(sizeof(G.traps[0]) * NSIG); + if (!G_traps) + G_traps = xzalloc(sizeof(G_traps[0]) * NSIG); argv++; if (!*argv) { int i; /* No args: print all trapped */ for (i = 0; i < NSIG; ++i) { - if (G.traps[i]) { + if (G_traps[i]) { printf("trap -- "); - print_escaped(G.traps[i]); + print_escaped(G_traps[i]); /* note: bash adds "SIG", but only if invoked * as "bash". If called as "sh", or if set -o posix, * then it prints short signal names. @@ -9224,11 +9270,11 @@ static int FAST_FUNC builtin_trap(char **argv) continue; } - free(G.traps[sig]); - G.traps[sig] = xstrdup(new_cmd); + free(G_traps[sig]); + G_traps[sig] = xstrdup(new_cmd); debug_printf("trap: setting SIG%s (%i) to '%s'\n", - get_signame(sig), sig, G.traps[sig]); + get_signame(sig), sig, G_traps[sig]); /* There is no signal for 0 (EXIT) */ if (sig == 0) @@ -9268,6 +9314,7 @@ static int FAST_FUNC builtin_trap(char **argv) argv++; goto process_sig_list; } +#endif #if ENABLE_HUSH_TYPE /* http://www.opengroup.org/onlinepubs/9699919799/utilities/type.html */ -- cgit v1.2.3-55-g6feb From 10d5ece64ae6b2338a13a58340a03ff988d46a85 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 8 Jan 2017 18:28:43 +0100 Subject: hush: make set/unset builtins optional Signed-off-by: Denys Vlasenko --- shell/hush.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index e6e8c1baf..4604240d8 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -258,6 +258,20 @@ //config: help //config: Enable read builtin in hush. //config: +//config:config HUSH_SET +//config: bool "set builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable set builtin in hush. +//config: +//config:config HUSH_UNSET +//config: bool "unset builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable unset builtin in hush. +//config: //config:config MSH //config: bool "msh (deprecated: aliased to hush)" //config: default n @@ -920,7 +934,9 @@ static int builtin_pwd(char **argv) FAST_FUNC; #if ENABLE_HUSH_READ static int builtin_read(char **argv) FAST_FUNC; #endif +#if ENABLE_HUSH_SET static int builtin_set(char **argv) FAST_FUNC; +#endif static int builtin_shift(char **argv) FAST_FUNC; static int builtin_source(char **argv) FAST_FUNC; static int builtin_test(char **argv) FAST_FUNC; @@ -932,7 +948,9 @@ static int builtin_type(char **argv) FAST_FUNC; #endif static int builtin_true(char **argv) FAST_FUNC; static int builtin_umask(char **argv) FAST_FUNC; +#if ENABLE_HUSH_UNSET static int builtin_unset(char **argv) FAST_FUNC; +#endif #if ENABLE_HUSH_KILL static int builtin_kill(char **argv) FAST_FUNC; #endif @@ -1008,7 +1026,9 @@ static const struct built_in_command bltins1[] = { #if ENABLE_HUSH_FUNCTIONS BLTIN("return" , builtin_return , "Return from a function"), #endif +#if ENABLE_HUSH_SET BLTIN("set" , builtin_set , "Set/unset positional parameters"), +#endif BLTIN("shift" , builtin_shift , "Shift positional parameters"), #if ENABLE_HUSH_BASH_COMPAT BLTIN("source" , builtin_source , "Run commands in a file"), @@ -1021,10 +1041,12 @@ static const struct built_in_command bltins1[] = { BLTIN("type" , builtin_type , "Show command type"), #endif #if ENABLE_HUSH_ULIMIT - BLTIN("ulimit" , shell_builtin_ulimit , "Control resource limits"), + BLTIN("ulimit" , shell_builtin_ulimit, "Control resource limits"), #endif BLTIN("umask" , builtin_umask , "Set file creation mask"), +#if ENABLE_HUSH_UNSET BLTIN("unset" , builtin_unset , "Unset variables"), +#endif #if ENABLE_HUSH_WAIT BLTIN("wait" , builtin_wait , "Wait for process"), #endif @@ -2107,10 +2129,12 @@ static int unset_local_var_len(const char *name, int name_len) return EXIT_SUCCESS; } +#if ENABLE_HUSH_UNSET static int unset_local_var(const char *name) { return unset_local_var_len(name, strlen(name)); } +#endif static void unset_vars(char **strings) { @@ -6712,6 +6736,7 @@ static struct function *new_function(char *name) return funcp; } +# if ENABLE_HUSH_UNSET static void unset_func(const char *name) { struct function **funcpp = find_function_slot(name); @@ -6727,13 +6752,14 @@ static void unset_func(const char *name) if (funcp->body) { free_pipe_list(funcp->body); free(funcp->name); -# if !BB_MMU +# if !BB_MMU free(funcp->body_as_string); -# endif +# endif } free(funcp); } } +# endif # if BB_MMU #define exec_function(to_free, funcp, argv) \ @@ -9016,6 +9042,7 @@ static int FAST_FUNC builtin_local(char **argv) } #endif +#if ENABLE_HUSH_UNSET /* http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#unset */ static int FAST_FUNC builtin_unset(char **argv) { @@ -9043,16 +9070,18 @@ static int FAST_FUNC builtin_unset(char **argv) ret = EXIT_FAILURE; } } -#if ENABLE_HUSH_FUNCTIONS +# if ENABLE_HUSH_FUNCTIONS else { unset_func(*argv); } -#endif +# endif argv++; } return ret; } +#endif +#if ENABLE_HUSH_SET /* http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set * built-in 'set' handler * SUSv3 says: @@ -9135,6 +9164,7 @@ static int FAST_FUNC builtin_set(char **argv) bb_error_msg("set: %s: invalid option", arg); return EXIT_FAILURE; } +#endif static int FAST_FUNC builtin_shift(char **argv) { -- cgit v1.2.3-55-g6feb From d5933b112537f9cb9d6ebb0109a0a38cea71fa63 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 8 Jan 2017 18:31:39 +0100 Subject: hush: make umask builtin optional Signed-off-by: Denys Vlasenko --- shell/hush.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index 4604240d8..a713a9680 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -272,6 +272,13 @@ //config: help //config: Enable unset builtin in hush. //config: +//config:config HUSH_UMASK +//config: bool "umask builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable umask builtin in hush. +//config: //config:config MSH //config: bool "msh (deprecated: aliased to hush)" //config: default n @@ -947,7 +954,9 @@ static int builtin_trap(char **argv) FAST_FUNC; static int builtin_type(char **argv) FAST_FUNC; #endif static int builtin_true(char **argv) FAST_FUNC; +#if ENABLE_HUSH_UMASK static int builtin_umask(char **argv) FAST_FUNC; +#endif #if ENABLE_HUSH_UNSET static int builtin_unset(char **argv) FAST_FUNC; #endif @@ -1043,7 +1052,9 @@ static const struct built_in_command bltins1[] = { #if ENABLE_HUSH_ULIMIT BLTIN("ulimit" , shell_builtin_ulimit, "Control resource limits"), #endif +#if ENABLE_HUSH_UMASK BLTIN("umask" , builtin_umask , "Set file creation mask"), +#endif #if ENABLE_HUSH_UNSET BLTIN("unset" , builtin_unset , "Unset variables"), #endif @@ -9610,6 +9621,7 @@ static int FAST_FUNC builtin_source(char **argv) return G.last_exitcode; } +#if ENABLE_HUSH_UMASK static int FAST_FUNC builtin_umask(char **argv) { int rc; @@ -9646,6 +9658,7 @@ static int FAST_FUNC builtin_umask(char **argv) return !rc; /* rc != 0 - success */ } +#endif #if ENABLE_HUSH_KILL static int FAST_FUNC builtin_kill(char **argv) -- cgit v1.2.3-55-g6feb From 6ec76d8719279dbda0b2a98163625b6f2ea013ff Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 8 Jan 2017 18:40:41 +0100 Subject: hush: make export builtin optional Signed-off-by: Denys Vlasenko --- shell/hush.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index a713a9680..153867614 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -187,13 +187,6 @@ //config: Enable pseudorandom generator and dynamic variable "$RANDOM". //config: Each read of "$RANDOM" will generate a new pseudorandom value. //config: -//config:config HUSH_EXPORT_N -//config: bool "Support 'export -n' option" -//config: default y -//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: export -n unexports variables. It is a bash extension. -//config: //config:config HUSH_MODE_X //config: bool "Support 'hush -x' option and 'set -x' command" //config: default y @@ -202,6 +195,20 @@ //config: This instructs hush to print commands before execution. //config: Adds ~300 bytes. //config: +//config:config HUSH_EXPORT +//config: bool "export builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable export builtin in hush. +//config: +//config:config HUSH_EXPORT_N +//config: bool "Support 'export -n' option" +//config: default y +//config: depends on HUSH_EXPORT +//config: help +//config: export -n unexports variables. It is a bash extension. +//config: //config:config HUSH_HELP //config: bool "help builtin" //config: default y @@ -917,7 +924,9 @@ static int builtin_echo(char **argv) FAST_FUNC; static int builtin_eval(char **argv) FAST_FUNC; static int builtin_exec(char **argv) FAST_FUNC; static int builtin_exit(char **argv) FAST_FUNC; +#if ENABLE_HUSH_EXPORT static int builtin_export(char **argv) FAST_FUNC; +#endif #if ENABLE_HUSH_JOB static int builtin_fg_bg(char **argv) FAST_FUNC; static int builtin_jobs(char **argv) FAST_FUNC; @@ -1007,7 +1016,9 @@ static const struct built_in_command bltins1[] = { BLTIN("eval" , builtin_eval , "Construct and run shell command"), BLTIN("exec" , builtin_exec , "Execute command, don't return to shell"), BLTIN("exit" , builtin_exit , "Exit"), +#if ENABLE_HUSH_EXPORT BLTIN("export" , builtin_export , "Set environment variables"), +#endif #if ENABLE_HUSH_JOB BLTIN("fg" , builtin_fg_bg , "Bring job into the foreground"), #endif @@ -8935,10 +8946,11 @@ static void print_escaped(const char *s) } while (*s); } -#if !ENABLE_HUSH_LOCAL +#if ENABLE_HUSH_EXPORT || ENABLE_HUSH_LOCAL +# if !ENABLE_HUSH_LOCAL #define helper_export_local(argv, exp, lvl) \ helper_export_local(argv, exp) -#endif +# endif static void helper_export_local(char **argv, int exp, int lvl) { do { @@ -8971,14 +8983,14 @@ static void helper_export_local(char **argv, int exp, int lvl) continue; } } -#if ENABLE_HUSH_LOCAL +# if ENABLE_HUSH_LOCAL if (exp == 0 /* local? */ && var && var->func_nest_level == lvl ) { /* "local x=abc; ...; local x" - ignore second local decl */ continue; } -#endif +# endif /* Exporting non-existing variable. * bash does not put it in environment, * but remembers that it is exported, @@ -8994,7 +9006,9 @@ static void helper_export_local(char **argv, int exp, int lvl) set_local_var(name, /*exp:*/ exp, /*lvl:*/ lvl, /*ro:*/ 0); } while (*++argv); } +#endif +#if ENABLE_HUSH_EXPORT static int FAST_FUNC builtin_export(char **argv) { unsigned opt_unexport; @@ -9040,6 +9054,7 @@ static int FAST_FUNC builtin_export(char **argv) return EXIT_SUCCESS; } +#endif #if ENABLE_HUSH_LOCAL static int FAST_FUNC builtin_local(char **argv) -- cgit v1.2.3-55-g6feb From 4471969db2102df9c97582b6577c7505caf64a34 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 8 Jan 2017 18:44:41 +0100 Subject: hush: make memleak builtin optional Signed-off-by: Denys Vlasenko --- shell/hush.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index 153867614..3050aeb8e 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -286,6 +286,13 @@ //config: help //config: Enable umask builtin in hush. //config: +//config:config HUSH_MEMLEAK +//config: bool "memleak builtin (debugging)" +//config: default n +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable umask builtin in hush. +//config: //config:config MSH //config: bool "msh (deprecated: aliased to hush)" //config: default n @@ -897,8 +904,10 @@ struct globals { # define G_traps ((char**)NULL) #endif sigset_t pending_set; -#if HUSH_DEBUG +#if ENABLE_HUSH_MEMLEAK unsigned long memleak_value; +#endif +#if HUSH_DEBUG int debug_indent; #endif struct sigaction sa; @@ -940,7 +949,7 @@ static int builtin_history(char **argv) FAST_FUNC; #if ENABLE_HUSH_LOCAL static int builtin_local(char **argv) FAST_FUNC; #endif -#if HUSH_DEBUG +#if ENABLE_HUSH_MEMLEAK static int builtin_memleak(char **argv) FAST_FUNC; #endif #if ENABLE_HUSH_PRINTF @@ -1037,7 +1046,7 @@ static const struct built_in_command bltins1[] = { #if ENABLE_HUSH_LOCAL BLTIN("local" , builtin_local , "Set local variables"), #endif -#if HUSH_DEBUG +#if ENABLE_HUSH_MEMLEAK BLTIN("memleak" , builtin_memleak , NULL), #endif #if ENABLE_HUSH_READ @@ -9534,7 +9543,7 @@ static int FAST_FUNC builtin_jobs(char **argv UNUSED_PARAM) } #endif -#if HUSH_DEBUG +#if ENABLE_HUSH_MEMLEAK static int FAST_FUNC builtin_memleak(char **argv UNUSED_PARAM) { void *p; -- cgit v1.2.3-55-g6feb From 41ade05cacd61a42e348f21aeddb7b12b0ad5d3d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 8 Jan 2017 18:56:24 +0100 Subject: hush: conditionalize print_escaped() on EXPORT || TRAP Signed-off-by: Denys Vlasenko --- shell/hush.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index 3050aeb8e..9b62d5c0d 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -8936,6 +8936,7 @@ static int FAST_FUNC builtin_exit(char **argv) hush_exit(xatoi(argv[0]) & 0xff); } +#if ENABLE_HUSH_EXPORT || ENABLE_HUSH_TRAP static void print_escaped(const char *s) { if (*s == '\'') @@ -8954,6 +8955,7 @@ static void print_escaped(const char *s) putchar('"'); } while (*s); } +#endif #if ENABLE_HUSH_EXPORT || ENABLE_HUSH_LOCAL # if !ENABLE_HUSH_LOCAL -- cgit v1.2.3-55-g6feb From 442a414d66266336e09eae2ea6713b5bf054475e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Jan 2017 05:11:09 +0100 Subject: typo fix Signed-off-by: Denys Vlasenko --- shell/hush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index 9b62d5c0d..01c334a46 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -291,7 +291,7 @@ //config: default n //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: help -//config: Enable umask builtin in hush. +//config: Enable memleak builtin in hush. //config: //config:config MSH //config: bool "msh (deprecated: aliased to hush)" -- cgit v1.2.3-55-g6feb From fd68f1e80dbed81e42a0298db5fcf578e8d944a9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Jan 2017 05:47:57 +0100 Subject: hush: fix kill builtin without jobs support Signed-off-by: Denys Vlasenko --- shell/hush.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index 01c334a46..247ad7aab 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -9443,7 +9443,7 @@ static struct pipe *parse_jobspec(const char *str) return pi; } } - bb_error_msg("%d: no such job", jobnum); + bb_error_msg("%u: no such job", jobnum); return NULL; } @@ -9691,9 +9691,9 @@ static int FAST_FUNC builtin_kill(char **argv) { int ret = 0; - argv = skip_dash_dash(argv); - if (argv[0] && strcmp(argv[0], "-l") != 0) { - int i = 0; +# if ENABLE_HUSH_JOB + if (argv[1] && strcmp(argv[1], "-l") != 0) { + int i = 1; do { struct pipe *pi; @@ -9735,12 +9735,9 @@ static int FAST_FUNC builtin_kill(char **argv) n = 1; dst = alloca(n * sizeof(int)*4); argv[i] = dst; -#if ENABLE_HUSH_JOB if (G_interactive_fd) dst += sprintf(dst, " -%u", (int)pi->pgrp); - else -#endif - for (j = 0; j < n; j++) { + else for (j = 0; j < n; j++) { struct command *cmd = &pi->cmds[j]; /* Skip exited members of the job */ if (cmd->pid == 0) @@ -9755,13 +9752,12 @@ static int FAST_FUNC builtin_kill(char **argv) *dst = '\0'; } while (argv[++i]); } +# endif - if (argv[0] || ret == 0) { - argv--; - argv[0] = (char*)"kill"; /* why? think about "kill -- PID" */ - /* kill_main also handles "killall" etc, so it does look at argv[0]! */ + if (argv[1] || ret == 0) { ret = run_applet_main(argv, kill_main); } + /* else: ret = 1, "kill %bad_jobspec" case */ return ret; } #endif -- cgit v1.2.3-55-g6feb From 5362cc4b8caa5c4b8bf815d8ac2fd50a0d8e9354 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Jan 2017 05:57:13 +0100 Subject: hush: remove redundand test for ENABLE_HUSH_JOB Signed-off-by: Denys Vlasenko --- shell/hush.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index 247ad7aab..c10793060 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -9730,9 +9730,7 @@ static int FAST_FUNC builtin_kill(char **argv) * sh -c 'true|sleep 2 & sleep 1; kill %1' * sh -c 'true|sleep 1 & sleep 2; kill %1' */ - n = pi->num_cmds; - if (ENABLE_HUSH_JOB && G_interactive_fd) - n = 1; + n = G_interactive_fd ? 1 : pi->num_cmds; dst = alloca(n * sizeof(int)*4); argv[i] = dst; if (G_interactive_fd) -- cgit v1.2.3-55-g6feb From cc2fd5a9867519da24672fae560e511a4a6940e7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Jan 2017 06:19:55 +0100 Subject: hush: fix 'defined but not used' warning Signed-off-by: Denys Vlasenko --- shell/hush.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index c10793060..faff86d88 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -2182,11 +2182,13 @@ static void unset_vars(char **strings) free(strings); } +#if ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_BASH_COMPAT || ENABLE_HUSH_READ static void FAST_FUNC set_local_var_from_halves(const char *name, const char *val) { char *var = xasprintf("%s=%s", name, val); set_local_var(var, /*flags:*/ 0, /*lvl:*/ 0, /*ro:*/ 0); } +#endif /* -- cgit v1.2.3-55-g6feb From 4e4f88e569e6e32669c856a86c60bb3fc104d588 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Jan 2017 07:57:38 +0100 Subject: hush: global_args_malloced is used only if set builtin is enabled function old new delta run_pipe 1623 1635 +12 builtin_source 210 222 +12 save_and_replace_G_args 70 60 -10 builtin_shift 132 94 -38 restore_G_args 98 - -98 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/2 up/down: 24/-146) Total: -122 bytes Signed-off-by: Denys Vlasenko --- shell/hush.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index faff86d88..c69e4ec8a 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -853,8 +853,13 @@ struct globals { smallint exiting; /* used to prevent EXIT trap recursion */ /* These four support $?, $#, and $1 */ smalluint last_exitcode; +#if ENABLE_HUSH_SET /* are global_argv and global_argv[1..n] malloced? (note: not [0]) */ smalluint global_args_malloced; +# define G_global_args_malloced (G.global_args_malloced) +#else +# define G_global_args_malloced 0 +#endif /* how many non-NULL argv's we have. NB: $# + 1 */ int global_argc; char **global_argv; @@ -893,7 +898,7 @@ struct globals { unsigned special_sig_mask; #if ENABLE_HUSH_JOB unsigned fatal_sig_mask; -# define G_fatal_sig_mask G.fatal_sig_mask +# define G_fatal_sig_mask (G.fatal_sig_mask) #else # define G_fatal_sig_mask 0 #endif @@ -1476,7 +1481,7 @@ typedef struct save_arg_t { char *sv_argv0; char **sv_g_argv; int sv_g_argc; - smallint sv_g_malloced; + IF_HUSH_SET(smallint sv_g_malloced;) } save_arg_t; static void save_and_replace_G_args(save_arg_t *sv, char **argv) @@ -1486,11 +1491,11 @@ static void save_and_replace_G_args(save_arg_t *sv, char **argv) sv->sv_argv0 = argv[0]; sv->sv_g_argv = G.global_argv; sv->sv_g_argc = G.global_argc; - sv->sv_g_malloced = G.global_args_malloced; + IF_HUSH_SET(sv->sv_g_malloced = G.global_args_malloced;) argv[0] = G.global_argv[0]; /* retain $0 */ G.global_argv = argv; - G.global_args_malloced = 0; + IF_HUSH_SET(G.global_args_malloced = 0;) n = 1; while (*++argv) @@ -1500,19 +1505,19 @@ static void save_and_replace_G_args(save_arg_t *sv, char **argv) static void restore_G_args(save_arg_t *sv, char **argv) { - char **pp; - +#if ENABLE_HUSH_SET if (G.global_args_malloced) { /* someone ran "set -- arg1 arg2 ...", undo */ - pp = G.global_argv; + char **pp = G.global_argv; while (*++pp) /* note: does not free $0 */ free(*pp); free(G.global_argv); } +#endif argv[0] = sv->sv_argv0; G.global_argv = sv->sv_g_argv; G.global_argc = sv->sv_g_argc; - G.global_args_malloced = sv->sv_g_malloced; + IF_HUSH_SET(G.global_args_malloced = sv->sv_g_malloced;) } @@ -9213,7 +9218,7 @@ static int FAST_FUNC builtin_shift(char **argv) n = atoi(argv[0]); } if (n >= 0 && n < G.global_argc) { - if (G.global_args_malloced) { + if (G_global_args_malloced) { int m = 1; while (m <= n) free(G.global_argv[m++]); -- cgit v1.2.3-55-g6feb From 2b1559056cf32c42675ecd937796e1455bcb5c2c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Jan 2017 08:13:21 +0100 Subject: hush: fix a bug in argv restoration after sourcing a file if sourced file "shift"ed argvs so that $1 is NULL, restore wasn't done. Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-misc/source_argv_and_shift.right | 4 ++++ shell/ash_test/ash-misc/source_argv_and_shift.tests | 12 ++++++++++++ shell/hush.c | 6 ++++-- shell/hush_test/hush-misc/source_argv_and_shift.right | 4 ++++ shell/hush_test/hush-misc/source_argv_and_shift.tests | 12 ++++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 shell/ash_test/ash-misc/source_argv_and_shift.right create mode 100755 shell/ash_test/ash-misc/source_argv_and_shift.tests create mode 100644 shell/hush_test/hush-misc/source_argv_and_shift.right create mode 100755 shell/hush_test/hush-misc/source_argv_and_shift.tests (limited to 'shell') diff --git a/shell/ash_test/ash-misc/source_argv_and_shift.right b/shell/ash_test/ash-misc/source_argv_and_shift.right new file mode 100644 index 000000000..b15cc96e7 --- /dev/null +++ b/shell/ash_test/ash-misc/source_argv_and_shift.right @@ -0,0 +1,4 @@ +sourced_arg1:1 +arg1: +sourced_arg1:a +arg1:1 diff --git a/shell/ash_test/ash-misc/source_argv_and_shift.tests b/shell/ash_test/ash-misc/source_argv_and_shift.tests new file mode 100755 index 000000000..66353f3d7 --- /dev/null +++ b/shell/ash_test/ash-misc/source_argv_and_shift.tests @@ -0,0 +1,12 @@ +echo 'echo sourced_arg1:$1' >sourced1 +echo 'shift' >>sourced1 + +set -- 1 +. ./sourced1 +echo arg1:$1 + +set -- 1 +. ./sourced1 a +echo arg1:$1 + +rm sourced1 diff --git a/shell/hush.c b/shell/hush.c index c69e4ec8a..5c5715b3f 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -9606,6 +9606,7 @@ static int FAST_FUNC builtin_source(char **argv) char *arg_path, *filename; FILE *input; save_arg_t sv; + char *args_need_save; #if ENABLE_HUSH_FUNCTIONS smallint sv_flg; #endif @@ -9637,7 +9638,8 @@ static int FAST_FUNC builtin_source(char **argv) /* "we are inside sourced file, ok to use return" */ G_flag_return_in_progress = -1; #endif - if (argv[1]) + args_need_save = argv[1]; /* used as a boolean variable */ + if (args_need_save) save_and_replace_G_args(&sv, argv); /* "false; . ./empty_line; echo Zero:$?" should print 0 */ @@ -9645,7 +9647,7 @@ static int FAST_FUNC builtin_source(char **argv) parse_and_run_file(input); fclose_and_forget(input); - if (argv[1]) + if (args_need_save) /* can't use argv[1] instead: "shift" can mangle it */ restore_G_args(&sv, argv); #if ENABLE_HUSH_FUNCTIONS G_flag_return_in_progress = sv_flg; diff --git a/shell/hush_test/hush-misc/source_argv_and_shift.right b/shell/hush_test/hush-misc/source_argv_and_shift.right new file mode 100644 index 000000000..b15cc96e7 --- /dev/null +++ b/shell/hush_test/hush-misc/source_argv_and_shift.right @@ -0,0 +1,4 @@ +sourced_arg1:1 +arg1: +sourced_arg1:a +arg1:1 diff --git a/shell/hush_test/hush-misc/source_argv_and_shift.tests b/shell/hush_test/hush-misc/source_argv_and_shift.tests new file mode 100755 index 000000000..66353f3d7 --- /dev/null +++ b/shell/hush_test/hush-misc/source_argv_and_shift.tests @@ -0,0 +1,12 @@ +echo 'echo sourced_arg1:$1' >sourced1 +echo 'shift' >>sourced1 + +set -- 1 +. ./sourced1 +echo arg1:$1 + +set -- 1 +. ./sourced1 a +echo arg1:$1 + +rm sourced1 -- cgit v1.2.3-55-g6feb From fb87d93d1e0a6760049fa88aadd1232b7e1545e7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Jan 2017 08:22:06 +0100 Subject: ash: fix a bug in argv restoration after sourcing a file if sourced file "shift"ed argvs so that $1 is NULL, restore wasn't done. Signed-off-by: Denys Vlasenko --- shell/ash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index efb4615db..9c46a93e0 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12548,6 +12548,7 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM) int status = 0; char *fullname; char **argv; + char *args_need_save; struct strlist *sp; volatile struct shparam saveparam; @@ -12567,7 +12568,8 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM) */ fullname = find_dot_file(argv[0]); argv++; - if (argv[0]) { /* . FILE ARGS, ARGS exist */ + args_need_save = argv[0]; + if (args_need_save) { /* . FILE ARGS, ARGS exist */ int argc; saveparam = shellparam; shellparam.malloced = 0; @@ -12586,7 +12588,7 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM) status = cmdloop(0); popfile(); - if (argv[0]) { + if (args_need_save) { freeparam(&shellparam); shellparam = saveparam; }; -- cgit v1.2.3-55-g6feb From 1cc6804f6980d2732df97f15933c93d34041dd83 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Jan 2017 17:10:04 +0100 Subject: hush: make echo builtin optional It's a bit overkill (who would want it off?) but ash already has it configurable. Let's be symmetric. Also tweak kbuild logic to use ASH_BUILTIN_ECHO to select echo.o, not ASH. Signed-off-by: Denys Vlasenko --- coreutils/Kbuild.src | 12 ++++-------- shell/hush.c | 29 ++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 17 deletions(-) (limited to 'shell') diff --git a/coreutils/Kbuild.src b/coreutils/Kbuild.src index 9ac6b9e78..d0b3f629b 100644 --- a/coreutils/Kbuild.src +++ b/coreutils/Kbuild.src @@ -14,15 +14,11 @@ lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty lib-$(CONFIG_LESS) += cat.o # less too lib-$(CONFIG_CRONTAB) += cat.o # crontab -l lib-$(CONFIG_ADDUSER) += chown.o # used by adduser -lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser +lib-$(CONFIG_ADDGROUP) += chown.o # used by addgroup lib-$(CONFIG_FTPD) += ls.o # used by ftpd -lib-$(CONFIG_ASH) += echo.o # used by ash -lib-$(CONFIG_SH_IS_ASH) += echo.o # used by ash -lib-$(CONFIG_BASH_IS_ASH) += echo.o # used by ash -lib-$(CONFIG_HUSH) += echo.o # used by hush -lib-$(CONFIG_SH_IS_HUSH) += echo.o # used by hush -lib-$(CONFIG_BASH_IS_HUSH) += echo.o # used by hush +lib-$(CONFIG_ASH_BUILTIN_ECHO) += echo.o +lib-$(CONFIG_HUSH_ECHO) += echo.o lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o -lib-$(CONFIG_HUSH_PRINTF) += printf.o +lib-$(CONFIG_HUSH_PRINTF) += printf.o diff --git a/shell/hush.c b/shell/hush.c index 5c5715b3f..22d71cb07 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -195,6 +195,20 @@ //config: This instructs hush to print commands before execution. //config: Adds ~300 bytes. //config: +//config:config HUSH_ECHO +//config: bool "echo builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable echo builtin in hush. +//config: +//config:config HUSH_PRINTF +//config: bool "printf builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: help +//config: Enable printf builtin in hush. +//config: //config:config HUSH_EXPORT //config: bool "export builtin" //config: default y @@ -216,13 +230,6 @@ //config: help //config: Enable help builtin in hush. Code size + ~1 kbyte. //config: -//config:config HUSH_PRINTF -//config: bool "printf builtin" -//config: default y -//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable printf builtin in hush. -//config: //config:config HUSH_KILL //config: bool "kill builtin (for kill %jobspec)" //config: default y @@ -934,7 +941,9 @@ struct globals { /* Function prototypes for builtins */ static int builtin_cd(char **argv) FAST_FUNC; +#if ENABLE_HUSH_ECHO static int builtin_echo(char **argv) FAST_FUNC; +#endif static int builtin_eval(char **argv) FAST_FUNC; static int builtin_exec(char **argv) FAST_FUNC; static int builtin_exit(char **argv) FAST_FUNC; @@ -1091,7 +1100,9 @@ static const struct built_in_command bltins1[] = { * Maybe make it configurable? */ static const struct built_in_command bltins2[] = { BLTIN("[" , builtin_test , NULL), +#if ENABLE_HUSH_ECHO BLTIN("echo" , builtin_echo , NULL), +#endif #if ENABLE_HUSH_PRINTF BLTIN("printf" , builtin_printf , NULL), #endif @@ -8832,12 +8843,12 @@ static int FAST_FUNC builtin_test(char **argv) { return run_applet_main(argv, test_main); } - +#if ENABLE_HUSH_ECHO static int FAST_FUNC builtin_echo(char **argv) { return run_applet_main(argv, echo_main); } - +#endif #if ENABLE_HUSH_PRINTF static int FAST_FUNC builtin_printf(char **argv) { -- cgit v1.2.3-55-g6feb From f560422fa079b07a761a572ca4f9cf287c2cc47e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 10 Jan 2017 14:58:54 +0100 Subject: Big cleanup in config help and description Redundant help texts (one which only repeats the description) are deleted. Descriptions and help texts are trimmed. Some config options are moved, even across menus. No config option _names_ are changed. Signed-off-by: Denys Vlasenko --- Config.in | 32 +++++++++-- archival/Config.src | 10 ---- archival/ar.c | 2 +- archival/bbunzip.c | 4 +- archival/cpio.c | 4 +- archival/gzip.c | 4 +- archival/tar.c | 35 +++++------- console-tools/loadfont.c | 8 +-- console-tools/setconsole.c | 2 - coreutils/Config.src | 16 +----- coreutils/chown.c | 2 - coreutils/cp.c | 4 +- coreutils/dd.c | 4 +- coreutils/df.c | 8 ++- coreutils/echo.c | 6 +-- coreutils/env.c | 2 - coreutils/expand.c | 4 -- coreutils/head.c | 4 +- coreutils/install.c | 2 - coreutils/ls.c | 6 --- coreutils/md5_sha1_sum.c | 1 - coreutils/mkdir.c | 2 - coreutils/mv.c | 2 - coreutils/split.c | 2 +- coreutils/tail.c | 7 ++- coreutils/wc.c | 4 +- debianutils/run_parts.c | 2 - debianutils/start_stop_daemon.c | 13 ++--- editors/Config.src | 2 +- editors/diff.c | 2 - editors/vi.c | 33 ++++++------ findutils/find.c | 14 ----- init/init.c | 4 +- libbb/Config.src | 17 +----- loginutils/Config.src | 2 +- loginutils/addgroup.c | 6 +-- loginutils/adduser.c | 2 - loginutils/deluser.c | 2 +- loginutils/login.c | 6 +-- loginutils/su.c | 9 ++-- miscutils/devfsd.c | 2 +- miscutils/hdparm.c | 12 ++--- miscutils/last.c | 2 +- miscutils/less.c | 5 +- modutils/Config.src | 4 +- networking/ftpd.c | 2 +- networking/ftpgetput.c | 2 - networking/httpd.c | 10 ++-- networking/ifupdown.c | 8 +-- networking/ipcalc.c | 12 ++--- networking/netstat.c | 2 +- networking/tftp.c | 4 +- networking/traceroute.c | 2 - networking/udhcp/Config.src | 4 +- networking/wget.c | 16 +++--- procps/Config.src | 2 +- procps/pidof.c | 8 +-- procps/ps.c | 16 +++--- procps/uptime.c | 4 +- selinux/chcon.c | 2 - selinux/runcon.c | 2 - shell/ash.c | 85 +++++++++++++----------------- shell/hush.c | 68 ++++++------------------ util-linux/Config.src | 2 +- util-linux/dmesg.c | 2 +- util-linux/fbset.c | 4 +- util-linux/fdisk.c | 2 - util-linux/hwclock.c | 4 -- util-linux/mount.c | 2 +- util-linux/volume_id/bcache.c | 4 -- util-linux/volume_id/btrfs.c | 4 -- util-linux/volume_id/cramfs.c | 4 -- util-linux/volume_id/exfat.c | 2 - util-linux/volume_id/ext.c | 4 -- util-linux/volume_id/f2fs.c | 2 - util-linux/volume_id/fat.c | 4 -- util-linux/volume_id/hfs.c | 4 -- util-linux/volume_id/iso9660.c | 4 -- util-linux/volume_id/jfs.c | 4 -- util-linux/volume_id/linux_raid.c | 4 -- util-linux/volume_id/linux_swap.c | 4 -- util-linux/volume_id/luks.c | 4 -- util-linux/volume_id/nilfs.c | 2 - util-linux/volume_id/ntfs.c | 4 -- util-linux/volume_id/ocfs2.c | 4 -- util-linux/volume_id/reiserfs.c | 4 -- util-linux/volume_id/romfs.c | 4 -- util-linux/volume_id/squashfs.c | 2 - util-linux/volume_id/sysv.c | 4 -- util-linux/volume_id/ubifs.c | 2 - util-linux/volume_id/udf.c | 4 -- util-linux/volume_id/unused_highpoint.c | 4 -- util-linux/volume_id/unused_hpfs.c | 4 -- util-linux/volume_id/unused_isw_raid.c | 4 -- util-linux/volume_id/unused_lsi_raid.c | 4 -- util-linux/volume_id/unused_lvm.c | 4 -- util-linux/volume_id/unused_mac.c | 4 -- util-linux/volume_id/unused_minix.c | 4 -- util-linux/volume_id/unused_msdos.c | 4 -- util-linux/volume_id/unused_nvidia_raid.c | 4 -- util-linux/volume_id/unused_promise_raid.c | 4 -- util-linux/volume_id/unused_silicon_raid.c | 4 -- util-linux/volume_id/unused_ufs.c | 4 -- util-linux/volume_id/unused_via_raid.c | 4 -- util-linux/volume_id/xfs.c | 4 -- 105 files changed, 203 insertions(+), 512 deletions(-) (limited to 'shell') diff --git a/Config.in b/Config.in index 66f7787d2..db1587169 100644 --- a/Config.in +++ b/Config.in @@ -22,7 +22,7 @@ config DESKTOP If you are preparing your build to be used on an embedded box where you have tighter control over the entire set of userspace - tools, you can unselect this option for smaller code size. + tools, you can unselect this option for smaller code size. config EXTRA_COMPAT bool "Provide compatible behavior for rare corner cases (bigger code)" @@ -50,6 +50,26 @@ config USE_PORTABLE_CODE compiler other than gcc. If you do use gcc, this option may needlessly increase code size. +#fixme: delete, create suboptions for applets which use this +config FEATURE_AUTOWIDTH + bool "Calculate terminal & column widths" + default y + help + This option allows utilities such as 'ls', 'telnet' etc + to determine the width of the screen, which can allow them to + display additional text or avoid wrapping text onto the next line. + If you leave this disabled, your utilities will be especially + primitive and will be unable to determine the current screen width. + +#fixme: delete, create suboptions for applets which use this +config FEATURE_USE_TERMIOS + bool "Use termios for one-stroke input" + default y + help + This option allows utilities such as 'top' to accept keyboard + commands. Without this option, they simply refresh display + after a fixed period. + config SHOW_USAGE bool "Show applet usage messages" default y @@ -113,14 +133,14 @@ config INSTALL_NO_USR never to /usr/bin or /usr/sbin. config PAM - bool "Support for PAM (Pluggable Authentication Modules)" + bool "Support PAM (Pluggable Authentication Modules)" default n help Use PAM in some busybox applets (currently login and httpd) instead of direct access to password database. config LONG_OPTS - bool "Support for --long-options" + bool "Support --long-options" default y help Enable this if you want busybox applets to use the gnu --long-option @@ -187,7 +207,7 @@ config PID_FILE_PATH specify a pidfile path. config FEATURE_SUID - bool "Support for SUID/SGID handling" + bool "Support SUID/SGID handling" default y help With this option you can install the busybox binary belonging @@ -611,6 +631,8 @@ config DEBUG_SANITIZE catch bad memory accesses (e.g. buffer overflows), but will make the executable larger and slow down runtime a bit. + This adds -fsanitize=foo options to gcc command line. + If you aren't developing/testing busybox, say N here. config UNIT_TEST @@ -625,7 +647,7 @@ config WERROR bool "Abort compilation on any warning" default n help - Selecting this will add -Werror to gcc command line. + This adds -Werror to gcc command line. Most people should answer N. diff --git a/archival/Config.src b/archival/Config.src index 5e7cfc0a4..0c97f3d7c 100644 --- a/archival/Config.src +++ b/archival/Config.src @@ -8,32 +8,22 @@ menu "Archival Utilities" config FEATURE_SEAMLESS_XZ bool "Make tar, rpm, modprobe etc understand .xz data" default y - help - Make tar, rpm, modprobe etc understand .xz data. config FEATURE_SEAMLESS_LZMA bool "Make tar, rpm, modprobe etc understand .lzma data" default y - help - Make tar, rpm, modprobe etc understand .lzma data. config FEATURE_SEAMLESS_BZ2 bool "Make tar, rpm, modprobe etc understand .bz2 data" default y - help - Make tar, rpm, modprobe etc understand .bz2 data. config FEATURE_SEAMLESS_GZ bool "Make tar, rpm, modprobe etc understand .gz data" default y - help - Make tar, rpm, modprobe etc understand .gz data. config FEATURE_SEAMLESS_Z bool "Make tar, rpm, modprobe etc understand .Z data" default n # it is ancient - help - Make tar, rpm, modprobe etc understand .Z data. INSERT diff --git a/archival/ar.c b/archival/ar.c index e49d5cb2b..d119c75ad 100644 --- a/archival/ar.c +++ b/archival/ar.c @@ -31,7 +31,7 @@ //config: probably say N here: most compilers come with their own ar utility. //config: //config:config FEATURE_AR_LONG_FILENAMES -//config: bool "Support for long filenames (not needed for debs)" +//config: bool "Support long filenames (not needed for debs)" //config: default y //config: depends on AR //config: help diff --git a/archival/bbunzip.c b/archival/bbunzip.c index aa8453440..fb7a3678d 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -312,8 +312,6 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv) //config: bool "Enable long options" //config: default y //config: depends on (GUNZIP || ZCAT) && LONG_OPTS -//config: help -//config: Enable use of long options. //applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP)) //applet:IF_ZCAT(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat)) @@ -522,7 +520,7 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv) //config: IOW: you'll get lzma applet, but it will always require -d option. //config: //config:config FEATURE_LZMA_FAST -//config: bool "Optimize unlzma for speed" +//config: bool "Optimize for speed" //config: default n //config: depends on UNLZMA || LZCAT || LZMA //config: help diff --git a/archival/cpio.c b/archival/cpio.c index 540218cb2..683f0bb1f 100644 --- a/archival/cpio.c +++ b/archival/cpio.c @@ -29,7 +29,7 @@ //config: should probably say N here. //config: //config:config FEATURE_CPIO_O -//config: bool "Support for archive creation" +//config: bool "Support archive creation" //config: default y //config: depends on CPIO //config: help @@ -37,7 +37,7 @@ //config: format only. //config: //config:config FEATURE_CPIO_P -//config: bool "Support for passthrough mode" +//config: bool "Support passthrough mode" //config: default y //config: depends on FEATURE_CPIO_O //config: help diff --git a/archival/gzip.c b/archival/gzip.c index 63bf76053..e698c26cd 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -48,11 +48,9 @@ aa: 85.1% -- replaced with aa.gz //config: bool "Enable long options" //config: default y //config: depends on GZIP && LONG_OPTS -//config: help -//config: Enable use of long options, increases size by about 106 Bytes //config: //config:config GZIP_FAST -//config: int "Trade memory for gzip speed (0:small,slow - 2:fast,big)" +//config: int "Trade memory for speed (0:small,slow - 2:fast,big)" //config: default 0 //config: range 0 2 //config: depends on GZIP diff --git a/archival/tar.c b/archival/tar.c index 8e315c610..b1d58a2df 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -49,13 +49,15 @@ //config: create compressed archives. It's probably the most widely used //config: UNIX archive program. //config: +//config:config FEATURE_TAR_LONG_OPTIONS +//config: bool "Enable long options" +//config: default y +//config: depends on TAR && LONG_OPTS +//config: //config:config FEATURE_TAR_CREATE -//config: bool "Enable archive creation" +//config: bool "Enable -c (archive creation)" //config: default y //config: depends on TAR -//config: help -//config: If you enable this option you'll be able to create -//config: tar archives using the `-c' option. //config: //config:config FEATURE_TAR_AUTODETECT //config: bool "Autodetect compressed tarballs" @@ -74,7 +76,7 @@ //config: a list of files to include or exclude from an archive. //config: //config:config FEATURE_TAR_OLDGNU_COMPATIBILITY -//config: bool "Support for old tar header format" +//config: bool "Support old tar header format" //config: default y //config: depends on TAR || DPKG //config: help @@ -93,22 +95,12 @@ //config: tarballs still exist. //config: //config:config FEATURE_TAR_GNU_EXTENSIONS -//config: bool "Support for GNU tar extensions (long filenames)" +//config: bool "Support GNU tar extensions (long filenames)" //config: default y //config: depends on TAR || DPKG -//config: help -//config: With this option busybox supports GNU long filenames and -//config: linknames. -//config: -//config:config FEATURE_TAR_LONG_OPTIONS -//config: bool "Enable long options" -//config: default y -//config: depends on TAR && LONG_OPTS -//config: help -//config: Enable use of long options, increases size by about 400 Bytes //config: //config:config FEATURE_TAR_TO_COMMAND -//config: bool "Support for writing to an external program" +//config: bool "Support writing to an external program (--to-command)" //config: default y //config: depends on TAR && FEATURE_TAR_LONG_OPTIONS //config: help @@ -121,20 +113,17 @@ //config: default y //config: depends on TAR //config: help -//config: Enables use of user and group names in tar. This affects contents +//config: Enable use of user and group names in tar. This affects contents //config: listings (-t) and preserving permissions when unpacking (-p). //config: +200 bytes. //config: //config:config FEATURE_TAR_NOPRESERVE_TIME -//config: bool "Enable -m (do not preserve time) option" +//config: bool "Enable -m (do not preserve time) GNU option" //config: default y //config: depends on TAR -//config: help -//config: With this option busybox supports GNU tar -m -//config: (do not preserve time) option. //config: //config:config FEATURE_TAR_SELINUX -//config: bool "Support for extracting SELinux labels" +//config: bool "Support extracting SELinux labels" //config: default n //config: depends on TAR && SELINUX //config: help diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c index 52605baa1..29f723ec0 100644 --- a/console-tools/loadfont.c +++ b/console-tools/loadfont.c @@ -42,18 +42,14 @@ //config: depends on LOADFONT || SETFONT //config: //config:config FEATURE_LOADFONT_PSF2 -//config: bool "Support for PSF2 console fonts" +//config: bool "Support PSF2 console fonts" //config: default y //config: depends on LOADFONT || SETFONT -//config: help -//config: Support PSF2 console fonts. //config: //config:config FEATURE_LOADFONT_RAW -//config: bool "Support for old (raw) console fonts" +//config: bool "Support old (raw) console fonts" //config: default y //config: depends on LOADFONT || SETFONT -//config: help -//config: Support old (raw) console fonts. //applet:IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) //applet:IF_SETFONT(APPLET(setfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) diff --git a/console-tools/setconsole.c b/console-tools/setconsole.c index 58057268d..d47a33d59 100644 --- a/console-tools/setconsole.c +++ b/console-tools/setconsole.c @@ -19,8 +19,6 @@ //config: bool "Enable long options" //config: default y //config: depends on SETCONSOLE && LONG_OPTS -//config: help -//config: Support long options for the setconsole applet. //applet:IF_SETCONSOLE(APPLET(setconsole, BB_DIR_SBIN, BB_SUID_DROP)) diff --git a/coreutils/Config.src b/coreutils/Config.src index c056320f8..1d2fea1fb 100644 --- a/coreutils/Config.src +++ b/coreutils/Config.src @@ -27,25 +27,11 @@ config FEATURE_PRESERVE_HARDLINKS help Allow cp and mv to preserve hard links. -comment "Common options for ls, more and telnet" - depends on LS || MORE || TELNET - -config FEATURE_AUTOWIDTH - bool "Calculate terminal & column widths" - default y - depends on LS || MORE || TELNET - help - This option allows utilities such as 'ls', 'more' and 'telnet' - to determine the width of the screen, which can allow them to - display additional text or avoid wrapping text onto the next line. - If you leave this disabled, your utilities will be especially - primitive and will be unable to determine the current screen width. - comment "Common options for df, du, ls" depends on DF || DU || LS config FEATURE_HUMAN_READABLE - bool "Support for human readable output (example 13k, 23M, 235G)" + bool "Support human readable output (example 13k, 23M, 235G)" default y depends on DF || DU || LS help diff --git a/coreutils/chown.c b/coreutils/chown.c index 50b06d73a..12cd0eacc 100644 --- a/coreutils/chown.c +++ b/coreutils/chown.c @@ -17,8 +17,6 @@ //config: bool "Enable long options" //config: default y //config: depends on CHOWN && LONG_OPTS -//config: help -//config: Enable use of long options //applet:IF_CHOWN(APPLET_NOEXEC(chown, chown, BB_DIR_BIN, BB_SUID_DROP, chown)) diff --git a/coreutils/cp.c b/coreutils/cp.c index 4ecdaafda..1e5f36d10 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -18,11 +18,11 @@ //config: cp is used to copy files and directories. //config: //config:config FEATURE_CP_LONG_OPTIONS -//config: bool "Enable long options for cp" +//config: bool "Enable long options" //config: default y //config: depends on CP && LONG_OPTS //config: help -//config: Enable long options for cp. +//config: Enable long options. //config: Also add support for --parents option. //applet:IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp)) diff --git a/coreutils/dd.c b/coreutils/dd.c index 3d1ba2ee6..5e68087fc 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -41,7 +41,7 @@ //config: default y //config: depends on DD //config: help -//config: Enables support for writing a certain number of bytes in and out, +//config: Enable support for writing a certain number of bytes in and out, //config: at a time, and performing conversions on the data stream. //config: //config:config FEATURE_DD_STATUS @@ -49,7 +49,7 @@ //config: default y //config: depends on DD //config: help -//config: Enables support for status=noxfer/none option. +//config: Enable support for status=noxfer/none option. //applet:IF_DD(APPLET_NOEXEC(dd, dd, BB_DIR_BIN, BB_SUID_DROP, dd)) diff --git a/coreutils/df.c b/coreutils/df.c index 79e4c4670..cf367161a 100644 --- a/coreutils/df.c +++ b/coreutils/df.c @@ -29,11 +29,9 @@ //config: default y //config: depends on DF //config: help -//config: This option enables -a, -i and -B. -//config: -//config: -a Show all filesystems -//config: -i Inodes -//config: -B Blocksize +//config: -a Show all filesystems +//config: -i Inodes +//config: -B Blocksize //applet:IF_DF(APPLET(df, BB_DIR_BIN, BB_SUID_DROP)) diff --git a/coreutils/echo.c b/coreutils/echo.c index fd0d9b780..d0dba650d 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c @@ -26,11 +26,9 @@ //config: //config:# this entry also appears in shell/Config.in, next to the echo builtin //config:config FEATURE_FANCY_ECHO -//config: bool "Enable echo options (-n and -e)" +//config: bool "Enable -n and -e options" //config: default y -//config: depends on ECHO || ASH_BUILTIN_ECHO || HUSH -//config: help -//config: This adds options (-n and -e) to echo. +//config: depends on ECHO || ASH_BUILTIN_ECHO || HUSH_ECHO //applet:IF_ECHO(APPLET_NOFORK(echo, echo, BB_DIR_BIN, BB_SUID_DROP, echo)) diff --git a/coreutils/env.c b/coreutils/env.c index e91eddb5c..2bd5f41d0 100644 --- a/coreutils/env.c +++ b/coreutils/env.c @@ -35,8 +35,6 @@ //config: bool "Enable long options" //config: default y //config: depends on ENV && LONG_OPTS -//config: help -//config: Support long options for the env applet. //applet:IF_ENV(APPLET_NOEXEC(env, env, BB_DIR_USR_BIN, BB_SUID_DROP, env)) diff --git a/coreutils/expand.c b/coreutils/expand.c index bb59af46d..29affc932 100644 --- a/coreutils/expand.c +++ b/coreutils/expand.c @@ -30,8 +30,6 @@ //config: bool "Enable long options" //config: default y //config: depends on EXPAND && LONG_OPTS -//config: help -//config: Support long options for the expand applet. //config: //config:config UNEXPAND //config: bool "unexpand" @@ -43,8 +41,6 @@ //config: bool "Enable long options" //config: default y //config: depends on UNEXPAND && LONG_OPTS -//config: help -//config: Support long options for the unexpand applet. //applet:IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP)) //applet:IF_UNEXPAND(APPLET_ODDNAME(unexpand, expand, BB_DIR_USR_BIN, BB_SUID_DROP, unexpand)) diff --git a/coreutils/head.c b/coreutils/head.c index 176e91e3a..d49113e7f 100644 --- a/coreutils/head.c +++ b/coreutils/head.c @@ -14,11 +14,9 @@ //config: from files. //config: //config:config FEATURE_FANCY_HEAD -//config: bool "Enable head options (-c, -q, and -v)" +//config: bool "Enable -c, -q, and -v" //config: default y //config: depends on HEAD -//config: help -//config: This enables the head options (-c, -q, and -v). //applet:IF_HEAD(APPLET_NOEXEC(head, head, BB_DIR_USR_BIN, BB_SUID_DROP, head)) diff --git a/coreutils/install.c b/coreutils/install.c index 831f9b802..2a642bdb6 100644 --- a/coreutils/install.c +++ b/coreutils/install.c @@ -15,8 +15,6 @@ //config: bool "Enable long options" //config: default y //config: depends on INSTALL && LONG_OPTS -//config: help -//config: Support long options for the install applet. //applet:IF_INSTALL(APPLET(install, BB_DIR_USR_BIN, BB_SUID_DROP)) diff --git a/coreutils/ls.c b/coreutils/ls.c index 0f35c70d5..531eb85b5 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -37,22 +37,16 @@ //config: bool "Enable filetyping options (-p and -F)" //config: default y //config: depends on LS -//config: help -//config: Enable the ls options (-p and -F). //config: //config:config FEATURE_LS_FOLLOWLINKS //config: bool "Enable symlinks dereferencing (-L)" //config: default y //config: depends on LS -//config: help -//config: Enable the ls option (-L). //config: //config:config FEATURE_LS_RECURSIVE //config: bool "Enable recursion (-R)" //config: default y //config: depends on LS -//config: help -//config: Enable the ls option (-R). //config: //config:config FEATURE_LS_SORTFILES //config: bool "Sort the file names" diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 783f44027..76788554c 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c @@ -45,7 +45,6 @@ //config: help //config: Enabling the -c options allows files to be checked //config: against pre-calculated hash values. -//config: //config: -s and -w are useful options when verifying checksums. //applet:IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, md5sum)) diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index 3afe76c28..fcc34f1ad 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c @@ -23,8 +23,6 @@ //config: bool "Enable long options" //config: default y //config: depends on MKDIR && LONG_OPTS -//config: help -//config: Support long options for the mkdir applet. //applet:IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, BB_DIR_BIN, BB_SUID_DROP, mkdir)) diff --git a/coreutils/mv.c b/coreutils/mv.c index 1cc318fd1..df2ef0a52 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c @@ -21,8 +21,6 @@ //config: bool "Enable long options" //config: default y //config: depends on MV && LONG_OPTS -//config: help -//config: Support long options for the mv applet. //applet:IF_MV(APPLET(mv, BB_DIR_BIN, BB_SUID_DROP)) diff --git a/coreutils/split.c b/coreutils/split.c index 50918a1ce..7af359d0e 100644 --- a/coreutils/split.c +++ b/coreutils/split.c @@ -9,7 +9,7 @@ //config: bool "split" //config: default y //config: help -//config: split a file into pieces. +//config: Split a file into pieces. //config: //config:config FEATURE_SPLIT_FANCY //config: bool "Fancy extensions" diff --git a/coreutils/tail.c b/coreutils/tail.c index 99f58ddd8..e7a24a7a8 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c @@ -26,13 +26,12 @@ //config: from files. //config: //config:config FEATURE_FANCY_TAIL -//config: bool "Enable extra tail options (-q, -s, -v, and -F)" +//config: bool "Enable -q, -s, -v, and -F options" //config: default y //config: depends on TAIL //config: help -//config: The options (-q, -s, -v and -F) are provided by GNU tail, but -//config: are not specific in the SUSv3 standard. -//config: +//config: These options are provided by GNU tail, but +//config: are not specific in the SUSv3 standard: //config: -q Never output headers giving file names //config: -s SEC Wait SEC seconds between reads with -f //config: -v Always output headers giving file names diff --git a/coreutils/wc.c b/coreutils/wc.c index 73837141e..4c53049b0 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c @@ -40,11 +40,11 @@ //config: in specified files. //config: //config:config FEATURE_WC_LARGE -//config: bool "Support very large files in wc" +//config: bool "Support very large counts" //config: default y //config: depends on WC //config: help -//config: Use "unsigned long long" in wc for counter variables. +//config: Use "unsigned long long" for counter variables. //applet:IF_WC(APPLET(wc, BB_DIR_USR_BIN, BB_SUID_DROP)) diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c index 0bb666abc..3ef28f1d4 100644 --- a/debianutils/run_parts.c +++ b/debianutils/run_parts.c @@ -41,8 +41,6 @@ //config: bool "Enable long options" //config: default y //config: depends on RUN_PARTS && LONG_OPTS -//config: help -//config: Support long options for the run-parts applet. //config: //config:config FEATURE_RUN_PARTS_FANCY //config: bool "Support additional arguments" diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index 3625ffee8..4a9e0653e 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c @@ -64,22 +64,19 @@ Misc options: //config: termination of system-level processes, usually the ones //config: started during the startup of the system. //config: +//config:config FEATURE_START_STOP_DAEMON_LONG_OPTIONS +//config: bool "Enable long options" +//config: default y +//config: depends on START_STOP_DAEMON && LONG_OPTS +//config: //config:config FEATURE_START_STOP_DAEMON_FANCY //config: bool "Support additional arguments" //config: default y //config: depends on START_STOP_DAEMON //config: help -//config: Support additional arguments. //config: -o|--oknodo ignored since we exit with 0 anyway //config: -v|--verbose //config: -N|--nicelevel N -//config: -//config:config FEATURE_START_STOP_DAEMON_LONG_OPTIONS -//config: bool "Enable long options" -//config: default y -//config: depends on START_STOP_DAEMON && LONG_OPTS -//config: help -//config: Support long options for the start-stop-daemon applet. //applet:IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, BB_DIR_SBIN, BB_SUID_DROP, start_stop_daemon)) diff --git a/editors/Config.src b/editors/Config.src index c6e9d92af..8f2b265bd 100644 --- a/editors/Config.src +++ b/editors/Config.src @@ -12,7 +12,7 @@ config FEATURE_ALLOW_EXEC default y depends on VI || AWK help - Enables vi and awk features which allows user to execute + Enables vi and awk features which allow user to execute shell commands (using system() C call). endmenu diff --git a/editors/diff.c b/editors/diff.c index 75229ad8c..0eb825cfb 100644 --- a/editors/diff.c +++ b/editors/diff.c @@ -88,8 +88,6 @@ //config: bool "Enable long options" //config: default y //config: depends on DIFF && LONG_OPTS -//config: help -//config: Enable use of long options. //config: //config:config FEATURE_DIFF_DIR //config: bool "Enable directory support" diff --git a/editors/vi.c b/editors/vi.c index 38a4692fd..b56b04bdd 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -30,7 +30,7 @@ //config: you may wish to use something else. //config: //config:config FEATURE_VI_MAX_LEN -//config: int "Maximum screen width in vi" +//config: int "Maximum screen width" //config: range 256 16384 //config: default 4096 //config: depends on VI @@ -39,7 +39,7 @@ //config: Make it smaller than 4k only if you are very limited on memory. //config: //config:config FEATURE_VI_8BIT -//config: bool "Allow vi to display 8-bit chars (otherwise shows dots)" +//config: bool "Allow to display 8-bit chars (otherwise shows dots)" //config: default n //config: depends on VI //config: help @@ -53,7 +53,7 @@ //config: default y //config: depends on VI //config: help -//config: Enable a limited set of colon commands for vi. This does not +//config: Enable a limited set of colon commands. This does not //config: provide an "ex" mode. //config: //config:config FEATURE_VI_YANKMARK @@ -61,16 +61,14 @@ //config: default y //config: depends on VI //config: help -//config: This will enable you to use yank and put, as well as mark in -//config: busybox vi. +//config: This will enable you to use yank and put, as well as mark. //config: //config:config FEATURE_VI_SEARCH //config: bool "Enable search and replace cmds" //config: default y //config: depends on VI //config: help -//config: Select this if you wish to be able to do search and replace in -//config: busybox vi. +//config: Select this if you wish to be able to do search and replace. //config: //config:config FEATURE_VI_REGEX_SEARCH //config: bool "Enable regex in search and replace" @@ -84,16 +82,15 @@ //config: default y //config: depends on VI //config: help -//config: Selecting this option will make busybox vi signal aware. This will -//config: make busybox vi support SIGWINCH to deal with Window Changes, catch -//config: Ctrl-Z and Ctrl-C and alarms. +//config: Selecting this option will make vi signal aware. This will support +//config: SIGWINCH to deal with Window Changes, catch ^Z and ^C and alarms. //config: //config:config FEATURE_VI_DOT_CMD //config: bool "Remember previous cmd and \".\" cmd" //config: default y //config: depends on VI //config: help -//config: Make busybox vi remember the last command and be able to repeat it. +//config: Make vi remember the last command and be able to repeat it. //config: //config:config FEATURE_VI_READONLY //config: bool "Enable -R option and \"view\" mode" @@ -104,25 +101,23 @@ //config: open a file in read-only mode. //config: //config:config FEATURE_VI_SETOPTS -//config: bool "Enable set-able options, ai ic showmatch" +//config: bool "Enable settable options, ai ic showmatch" //config: default y //config: depends on VI //config: help //config: Enable the editor to set some (ai, ic, showmatch) options. //config: //config:config FEATURE_VI_SET -//config: bool "Support for :set" +//config: bool "Support :set" //config: default y //config: depends on VI -//config: help -//config: Support for ":set". //config: //config:config FEATURE_VI_WIN_RESIZE //config: bool "Handle window resize" //config: default y //config: depends on VI //config: help -//config: Make busybox vi behave nicely with terminals that get resized. +//config: Behave nicely with terminals that get resized. //config: //config:config FEATURE_VI_ASK_TERMINAL //config: bool "Use 'tell me cursor position' ESC sequence to measure window" @@ -133,15 +128,16 @@ //config: this option makes vi perform a last-ditch effort to find it: //config: position cursor to 999,999 and ask terminal to report real //config: cursor position using "ESC [ 6 n" escape sequence, then read stdin. -//config: //config: This is not clean but helps a lot on serial lines and such. +//config: //config:config FEATURE_VI_UNDO -//config: bool "Support undo command 'u'" +//config: bool "Support undo command \"u\"" //config: default y //config: depends on VI //config: help //config: Support the 'u' command to undo insertion, deletion, and replacement //config: of text. +//config: //config:config FEATURE_VI_UNDO_QUEUE //config: bool "Enable undo operation queuing" //config: default y @@ -152,6 +148,7 @@ //config: reached, the contents of the queue are committed to the undo stack. //config: This increases the size of the undo code and allows some undo //config: operations (especially un-typing/backspacing) to be far more useful. +//config: //config:config FEATURE_VI_UNDO_QUEUE_MAX //config: int "Maximum undo character queue size" //config: default 256 diff --git a/findutils/find.c b/findutils/find.c index 27698e537..67aa40b21 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -89,8 +89,6 @@ //config: bool "Enable -perm: permissions matching" //config: default y //config: depends on FIND -//config: help -//config: Enable searching based on file permissions. //config: //config:config FEATURE_FIND_TYPE //config: bool "Enable -type: file type matching (file/dir/link/...)" @@ -104,15 +102,11 @@ //config: bool "Enable -xdev: 'stay in filesystem'" //config: default y //config: depends on FIND -//config: help -//config: This option allows find to restrict searches to a single filesystem. //config: //config:config FEATURE_FIND_MAXDEPTH //config: bool "Enable -mindepth N and -maxdepth N" //config: default y //config: depends on FIND -//config: help -//config: This option enables -mindepth N and -maxdepth N option. //config: //config:config FEATURE_FIND_NEWER //config: bool "Enable -newer: compare file modification times" @@ -126,8 +120,6 @@ //config: bool "Enable -inum: inode number matching" //config: default y //config: depends on FIND -//config: help -//config: Support the 'find -inum' option for searching by inode number. //config: //config:config FEATURE_FIND_EXEC //config: bool "Enable -exec: execute commands" @@ -151,15 +143,11 @@ //config: bool "Enable -user: username/uid matching" //config: default y //config: depends on FIND -//config: help -//config: Support the 'find -user' option for searching by username or uid. //config: //config:config FEATURE_FIND_GROUP //config: bool "Enable -group: group/gid matching" //config: default y //config: depends on FIND -//config: help -//config: Support the 'find -group' option for searching by group name or gid. //config: //config:config FEATURE_FIND_NOT //config: bool "Enable the 'not' (!) operator" @@ -188,8 +176,6 @@ //config: bool "Enable -size: file size matching" //config: default y //config: depends on FIND -//config: help -//config: Support the 'find -size' option for searching by file size. //config: //config:config FEATURE_FIND_PRUNE //config: bool "Enable -prune: exclude subdirectories" diff --git a/init/init.c b/init/init.c index 08cfa2f8c..8db4ced58 100644 --- a/init/init.c +++ b/init/init.c @@ -104,13 +104,13 @@ //config: sets TERM to "vt102" if one is found. //config: //config:config FEATURE_INIT_MODIFY_CMDLINE -//config: bool "Modify the command-line to \"init\"" +//config: bool "Clear init's command line" //config: default y //config: depends on INIT || LINUXRC //config: help //config: When launched as PID 1 and after parsing its arguments, init //config: wipes all the arguments but argv[0] and rewrites argv[0] to -//config: contain only "init", so that its command-line appears solely as +//config: contain only "init", so that its command line appears solely as //config: "init" in tools such as ps. //config: If this option is set to Y, init will keep its original behavior, //config: otherwise, all the arguments including argv[0] will be preserved, diff --git a/libbb/Config.src b/libbb/Config.src index 172fbcc0e..c51640305 100644 --- a/libbb/Config.src +++ b/libbb/Config.src @@ -70,24 +70,13 @@ config FEATURE_FAST_TOP but code size is slightly bigger. config FEATURE_ETC_NETWORKS - bool "Support for /etc/networks" + bool "Support /etc/networks" default n help Enable support for network names in /etc/networks. This is a rarely used feature which allows you to use names instead of IP/mask pairs in route command. -config FEATURE_USE_TERMIOS - bool "Use termios to manipulate the screen" - default y - depends on MORE || TOP || POWERTOP - help - This option allows utilities such as 'more' and 'top' to determine - the size of the screen. If you leave this disabled, your utilities - that display things on the screen will be especially primitive and - will be unable to determine the current screen size, and will be - unable to move the cursor. - config FEATURE_EDITING bool "Command line editing" default y @@ -147,15 +136,11 @@ config FEATURE_TAB_COMPLETION bool "Tab completion" default y depends on FEATURE_EDITING - help - Enable tab completion. config FEATURE_USERNAME_COMPLETION bool "Username completion" default y depends on FEATURE_TAB_COMPLETION - help - Enable username completion. config FEATURE_EDITING_FANCY_PROMPT bool "Fancy shell prompts" diff --git a/loginutils/Config.src b/loginutils/Config.src index efb954b6c..beb4eb855 100644 --- a/loginutils/Config.src +++ b/loginutils/Config.src @@ -6,7 +6,7 @@ menu "Login/Password Management Utilities" config FEATURE_SHADOWPASSWDS - bool "Support for shadow passwords" + bool "Support shadow passwords" default y help Build support for shadow password in /etc/shadow. This file is only diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c index 6b2fd7ba9..94da4efbb 100644 --- a/loginutils/addgroup.c +++ b/loginutils/addgroup.c @@ -19,15 +19,13 @@ //config: bool "Enable long options" //config: default y //config: depends on ADDGROUP && LONG_OPTS -//config: help -//config: Support long options for the addgroup applet. //config: //config:config FEATURE_ADDUSER_TO_GROUP -//config: bool "Support for adding users to groups" +//config: bool "Support adding users to groups" //config: default y //config: depends on ADDGROUP //config: help -//config: If called with two non-option arguments, +//config: If called with two non-option arguments, //config: addgroup will add an existing user to an //config: existing group. diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 608fb8437..c218ac4aa 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c @@ -17,8 +17,6 @@ //config: bool "Enable long options" //config: default y //config: depends on ADDUSER && LONG_OPTS -//config: help -//config: Support long options for the adduser applet. //config: //config:config FEATURE_CHECK_NAMES //config: bool "Enable sanity check on user/group names in adduser and addgroup" diff --git a/loginutils/deluser.c b/loginutils/deluser.c index 7c3caf9e3..fbb1614fb 100644 --- a/loginutils/deluser.c +++ b/loginutils/deluser.c @@ -21,7 +21,7 @@ //config: Utility for deleting a group account. //config: //config:config FEATURE_DEL_USER_FROM_GROUP -//config: bool "Support for removing users from groups" +//config: bool "Support removing users from groups" //config: default y //config: depends on DELGROUP //config: help diff --git a/loginutils/login.c b/loginutils/login.c index 3ca8213bb..d1757a65d 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -24,7 +24,7 @@ //config: will not be cleaned up. //config: //config:config LOGIN_SCRIPTS -//config: bool "Support for login scripts" +//config: bool "Support login scripts" //config: depends on LOGIN //config: default y //config: help @@ -32,7 +32,7 @@ //config: just prior to switching from root to logged-in user. //config: //config:config FEATURE_NOLOGIN -//config: bool "Support for /etc/nologin" +//config: bool "Support /etc/nologin" //config: default y //config: depends on LOGIN //config: help @@ -40,7 +40,7 @@ //config: If it exists, non-root logins are prohibited. //config: //config:config FEATURE_SECURETTY -//config: bool "Support for /etc/securetty" +//config: bool "Support /etc/securetty" //config: default y //config: depends on LOGIN //config: help diff --git a/loginutils/su.c b/loginutils/su.c index 24ffbde86..d04b85fb1 100644 --- a/loginutils/su.c +++ b/loginutils/su.c @@ -11,19 +11,18 @@ //config: help //config: su is used to become another user during a login session. //config: Invoked without a username, su defaults to becoming the super user. -//config: -//config: Note that Busybox binary must be setuid root for this applet to +//config: Note that busybox binary must be setuid root for this applet to //config: work properly. //config: //config:config FEATURE_SU_SYSLOG -//config: bool "Enable su to write to syslog" +//config: bool "Log to syslog all attempts to use su" //config: default y //config: depends on SU //config: //config:config FEATURE_SU_CHECKS_SHELLS -//config: bool "Enable su to check user's shell to be listed in /etc/shells" -//config: depends on SU +//config: bool "If user's shell is not in /etc/shells, disallow -s PROG" //config: default y +//config: depends on SU //applet:/* Needs to be run by root or be suid root - needs to change uid and gid: */ //applet:IF_SU(APPLET(su, BB_DIR_BIN, BB_SUID_REQUIRE)) diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 99bdc72b8..334f1071b 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c @@ -82,7 +82,7 @@ //config: the external modutils. //config: //config:config DEVFSD_FG_NP -//config: bool "Enables the -fg and -np options" +//config: bool "Enable the -fg and -np options" //config: default y //config: depends on DEVFSD //config: help diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index e43a0dec2..84675285a 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c @@ -25,7 +25,7 @@ //config: default y //config: depends on HDPARM //config: help -//config: Enables the -I and -i options to obtain detailed information +//config: Enable the -I and -i options to obtain detailed information //config: directly from drives about their capabilities and supported ATA //config: feature set. If no device name is specified, hdparm will read //config: identify data from stdin. Enabling this option will add about 16k... @@ -35,7 +35,7 @@ //config: default y //config: depends on HDPARM //config: help -//config: Enables the 'hdparm -R' option to register an IDE interface. +//config: Enable the 'hdparm -R' option to register an IDE interface. //config: This is dangerous stuff, so you should probably say N. //config: //config:config FEATURE_HDPARM_HDIO_UNREGISTER_HWIF @@ -43,7 +43,7 @@ //config: default y //config: depends on HDPARM //config: help -//config: Enables the 'hdparm -U' option to un-register an IDE interface. +//config: Enable the 'hdparm -U' option to un-register an IDE interface. //config: This is dangerous stuff, so you should probably say N. //config: //config:config FEATURE_HDPARM_HDIO_DRIVE_RESET @@ -51,7 +51,7 @@ //config: default y //config: depends on HDPARM //config: help -//config: Enables the 'hdparm -w' option to perform a device reset. +//config: Enable the 'hdparm -w' option to perform a device reset. //config: This is dangerous stuff, so you should probably say N. //config: //config:config FEATURE_HDPARM_HDIO_TRISTATE_HWIF @@ -59,7 +59,7 @@ //config: default y //config: depends on HDPARM //config: help -//config: Enables the 'hdparm -x' option to tristate device for hotswap, +//config: Enable the 'hdparm -x' option to tristate device for hotswap, //config: and the '-b' option to get/set bus state. This is dangerous //config: stuff, so you should probably say N. //config: @@ -68,7 +68,7 @@ //config: default y //config: depends on HDPARM //config: help -//config: Enables the 'hdparm -d' option to get/set using_dma flag. +//config: Enable the 'hdparm -d' option to get/set using_dma flag. //applet:IF_HDPARM(APPLET(hdparm, BB_DIR_SBIN, BB_SUID_DROP)) diff --git a/miscutils/last.c b/miscutils/last.c index 67c1343f1..b3f125c3f 100644 --- a/miscutils/last.c +++ b/miscutils/last.c @@ -14,7 +14,7 @@ //config: 'last' displays a list of the last users that logged into the system. //config: //config:config FEATURE_LAST_FANCY -//config: bool "Turn on output of extra information" +//config: bool "Output extra information" //config: default y //config: depends on LAST //config: help diff --git a/miscutils/less.c b/miscutils/less.c index e90691b49..0b0a9aed4 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -87,7 +87,6 @@ //config: this option makes less perform a last-ditch effort to find it: //config: position cursor to 999,999 and ask terminal to report real //config: cursor position using "ESC [ 6 n" escape sequence, then read stdin. -//config: //config: This is not clean but helps a lot on serial lines and such. //config: //config:config FEATURE_LESS_DASHCMD @@ -99,11 +98,9 @@ //config: less itself ('-' keyboard command). //config: //config:config FEATURE_LESS_LINENUMS -//config: bool "Enable dynamic switching of line numbers" +//config: bool "Enable -N (dynamic switching of line numbers)" //config: default y //config: depends on FEATURE_LESS_DASHCMD -//config: help -//config: Enables "-N" command. //applet:IF_LESS(APPLET(less, BB_DIR_USR_BIN, BB_SUID_DROP)) diff --git a/modutils/Config.src b/modutils/Config.src index 84ff34a08..1808f332d 100644 --- a/modutils/Config.src +++ b/modutils/Config.src @@ -133,7 +133,7 @@ config FEATURE_CHECK_TAINTED_MODULE This option is required to support GPLONLY modules. config FEATURE_MODUTILS_ALIAS - bool "Support for module.aliases file" + bool "Support module.aliases file" default y depends on DEPMOD || MODPROBE select PLATFORM_LINUX @@ -150,7 +150,7 @@ config FEATURE_MODUTILS_ALIAS Say Y if unsure. config FEATURE_MODUTILS_SYMBOLS - bool "Support for module.symbols file" + bool "Support module.symbols file" default y depends on DEPMOD || MODPROBE select PLATFORM_LINUX diff --git a/networking/ftpd.c b/networking/ftpd.c index bcd60a2ad..a4626c0b5 100644 --- a/networking/ftpd.c +++ b/networking/ftpd.c @@ -15,7 +15,7 @@ //config: bool "ftpd" //config: default y //config: help -//config: simple FTP daemon. You have to run it via inetd. +//config: Simple FTP daemon. You have to run it via inetd. //config: //config:config FEATURE_FTPD_WRITE //config: bool "Enable upload commands" diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 40a3271ab..35b4e4b64 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c @@ -28,8 +28,6 @@ //config: bool "Enable long options in ftpget/ftpput" //config: default y //config: depends on LONG_OPTS && (FTPGET || FTPPUT) -//config: help -//config: Support long options for the ftpget/ftpput applet. //applet:IF_FTPGET(APPLET_ODDNAME(ftpget, ftpgetput, BB_DIR_USR_BIN, BB_SUID_DROP, ftpget)) //applet:IF_FTPPUT(APPLET_ODDNAME(ftpput, ftpgetput, BB_DIR_USR_BIN, BB_SUID_DROP, ftpput)) diff --git a/networking/httpd.c b/networking/httpd.c index cfcd2a06e..39aad90a8 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -102,7 +102,7 @@ //config: bool "httpd" //config: default y //config: help -//config: Serve web pages via an HTTP server. +//config: HTTP server. //config: //config:config FEATURE_HTTPD_RANGES //config: bool "Support 'Ranges:' header" @@ -156,7 +156,7 @@ //config: when specific URLs are requested. //config: //config:config FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR -//config: bool "Support for running scripts through an interpreter" +//config: bool "Support running scripts through an interpreter" //config: default y //config: depends on FEATURE_HTTPD_CGI //config: help @@ -185,7 +185,7 @@ //config: "<Hello World>". //config: //config:config FEATURE_HTTPD_ERROR_PAGES -//config: bool "Support for custom error pages" +//config: bool "Support custom error pages" //config: default y //config: depends on HTTPD //config: help @@ -198,7 +198,7 @@ //config: message. //config: //config:config FEATURE_HTTPD_PROXY -//config: bool "Support for reverse proxy" +//config: bool "Support reverse proxy" //config: default y //config: depends on HTTPD //config: help @@ -210,7 +210,7 @@ //config: http://hostname[:port]/new/path/myfile. //config: //config:config FEATURE_HTTPD_GZIP -//config: bool "Support for GZIP content encoding" +//config: bool "Support GZIP content encoding" //config: default y //config: depends on HTTPD //config: help diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 1806a6ccc..78baa6690 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c @@ -66,14 +66,14 @@ //config: utilities, or enable these applets in Busybox. //config: //config:config FEATURE_IFUPDOWN_IPV4 -//config: bool "Support for IPv4" +//config: bool "Support IPv4" //config: default y //config: depends on IFUP || IFDOWN //config: help //config: If you want ifup/ifdown to talk IPv4, leave this on. //config: //config:config FEATURE_IFUPDOWN_IPV6 -//config: bool "Support for IPv6" +//config: bool "Support IPv6" //config: default y //config: depends on (IFUP || IFDOWN) && FEATURE_IPV6 //config: help @@ -81,7 +81,7 @@ //config: //UNUSED: ////////:config FEATURE_IFUPDOWN_IPX -////////: bool "Support for IPX" +////////: bool "Support IPX" ////////: default y ////////: depends on IFUP || IFDOWN ////////: help @@ -97,7 +97,7 @@ //config: a weird network setup you don't need it. //config: //config:config FEATURE_IFUPDOWN_EXTERNAL_DHCP -//config: bool "Support for external dhcp clients" +//config: bool "Support external DHCP clients" //config: default n //config: depends on IFUP || IFDOWN //config: help diff --git a/networking/ipcalc.c b/networking/ipcalc.c index 21219424f..9359f9016 100644 --- a/networking/ipcalc.c +++ b/networking/ipcalc.c @@ -18,6 +18,11 @@ //config: ipcalc takes an IP address and netmask and calculates the //config: resulting broadcast, network, and host range. //config: +//config:config FEATURE_IPCALC_LONG_OPTIONS +//config: bool "Enable long options" +//config: default y +//config: depends on IPCALC && LONG_OPTS +//config: //config:config FEATURE_IPCALC_FANCY //config: bool "Fancy IPCALC, more options, adds 1 kbyte" //config: default y @@ -25,13 +30,6 @@ //config: help //config: Adds the options hostname, prefix and silent to the output of //config: "ipcalc". -//config: -//config:config FEATURE_IPCALC_LONG_OPTIONS -//config: bool "Enable long options" -//config: default y -//config: depends on IPCALC && LONG_OPTS -//config: help -//config: Support long options for the ipcalc applet. //applet:IF_IPCALC(APPLET(ipcalc, BB_DIR_BIN, BB_SUID_DROP)) diff --git a/networking/netstat.c b/networking/netstat.c index 90da6cdb8..68e0c1a04 100644 --- a/networking/netstat.c +++ b/networking/netstat.c @@ -21,7 +21,7 @@ //config: netstat prints information about the Linux networking subsystem. //config: //config:config FEATURE_NETSTAT_WIDE -//config: bool "Enable wide netstat output" +//config: bool "Enable wide output" //config: default y //config: depends on NETSTAT //config: help diff --git a/networking/tftp.c b/networking/tftp.c index ed8672025..189364f0c 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -69,11 +69,9 @@ //config: "blksize" and "tsize" options. //config: //config:config FEATURE_TFTP_PROGRESS_BAR -//config: bool "Enable tftp progress meter" +//config: bool "Enable progress bar" //config: default y //config: depends on TFTP && FEATURE_TFTP_BLOCKSIZE -//config: help -//config: Show progress bar. //config: //config:config TFTP_DEBUG //config: bool "Enable debug" diff --git a/networking/traceroute.c b/networking/traceroute.c index a463b0faa..6817861ef 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -235,8 +235,6 @@ //config: bool "Enable -I option (use ICMP instead of UDP)" //config: default y //config: depends on TRACEROUTE || TRACEROUTE6 -//config: help -//config: Add option -I to use ICMP ECHO instead of UDP datagrams. /* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore BB_SUID_MAYBE: */ //applet:IF_TRACEROUTE(APPLET(traceroute, BB_DIR_USR_BIN, BB_SUID_MAYBE)) diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src index 7bc13a719..5c068441a 100644 --- a/networking/udhcp/Config.src +++ b/networking/udhcp/Config.src @@ -123,7 +123,7 @@ config UDHCP_DEBUG are very verbose and useful for debugging only. config FEATURE_UDHCP_RFC3397 - bool "Support for RFC3397 domain search (experimental)" + bool "Support RFC3397 domain search (experimental)" default y depends on UDHCPD || UDHCPC help @@ -132,7 +132,7 @@ config FEATURE_UDHCP_RFC3397 and SIP servers option 120, specified in RFC 3361. config FEATURE_UDHCP_8021Q - bool "Support for 802.1Q VLAN parameters" + bool "Support 802.1Q VLAN parameters" default y depends on UDHCPD || UDHCPC help diff --git a/networking/wget.c b/networking/wget.c index b082a0f59..c82086878 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -16,12 +16,15 @@ //config: wget is a utility for non-interactive download of files from HTTP //config: and FTP servers. //config: +//config:config FEATURE_WGET_LONG_OPTIONS +//config: bool "Enable long options" +//config: default y +//config: depends on WGET && LONG_OPTS +//config: //config:config FEATURE_WGET_STATUSBAR -//config: bool "Enable a nifty process meter (+2k)" +//config: bool "Enable progress bar (+2k)" //config: default y //config: depends on WGET -//config: help -//config: Enable the transfer progress bar for wget transfers. //config: //config:config FEATURE_WGET_AUTHENTICATION //config: bool "Enable HTTP authentication" @@ -30,13 +33,6 @@ //config: help //config: Support authenticated HTTP transfers. //config: -//config:config FEATURE_WGET_LONG_OPTIONS -//config: bool "Enable long options" -//config: default y -//config: depends on WGET && LONG_OPTS -//config: help -//config: Support long options for the wget applet. -//config: //config:config FEATURE_WGET_TIMEOUT //config: bool "Enable timeout option -T SEC" //config: default y diff --git a/procps/Config.src b/procps/Config.src index eb4760752..35fef2eda 100644 --- a/procps/Config.src +++ b/procps/Config.src @@ -8,7 +8,7 @@ menu "Process Utilities" INSERT config FEATURE_SHOW_THREADS - bool "Support for showing threads in ps/pstree/top" + bool "Support thread display in ps/pstree/top" default y depends on PS || TOP || PSTREE help diff --git a/procps/pidof.c b/procps/pidof.c index 069adb7a4..b64f0cbd6 100644 --- a/procps/pidof.c +++ b/procps/pidof.c @@ -14,18 +14,18 @@ //config: those id's on the standard output. //config: //config:config FEATURE_PIDOF_SINGLE -//config: bool "Enable argument for single shot (-s)" +//config: bool "Enable single shot (-s)" //config: default y //config: depends on PIDOF //config: help -//config: Support argument '-s' for returning only the first pid found. +//config: Support '-s' for returning only the first pid found. //config: //config:config FEATURE_PIDOF_OMIT -//config: bool "Enable argument for omitting pids (-o)" +//config: bool "Enable omitting pids (-o PID)" //config: default y //config: depends on PIDOF //config: help -//config: Support argument '-o' for omitting the given pids in output. +//config: Support '-o PID' for omitting the given pid(s) in output. //config: The special pid %PPID can be used to name the parent process //config: of the pidof, in other words the calling shell or shell script. diff --git a/procps/ps.c b/procps/ps.c index e291ecd7e..1d380590d 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -32,19 +32,10 @@ //config: Adds fields PPID, RSS, START, TIME & TTY //config: //config:config FEATURE_PS_TIME -//config: bool "Enable time and elapsed time output" +//config: bool "Support -o time and -o etime output specifiers" //config: default y //config: depends on PS && DESKTOP //config: select PLATFORM_LINUX -//config: help -//config: Support -o time and -o etime output specifiers. -//config: -//config:config FEATURE_PS_ADDITIONAL_COLUMNS -//config: bool "Enable additional ps columns" -//config: default y -//config: depends on PS && DESKTOP -//config: help -//config: Support -o rgroup, -o ruser, -o nice output specifiers. //config: //config:config FEATURE_PS_UNUSUAL_SYSTEMS //config: bool "Support Linux prior to 2.4.0 and non-ELF systems" @@ -53,6 +44,11 @@ //config: help //config: Include support for measuring HZ on old kernels and non-ELF systems //config: (if you are on Linux 2.4.0+ and use ELF, you don't need this) +//config: +//config:config FEATURE_PS_ADDITIONAL_COLUMNS +//config: bool "Support -o rgroup, -o ruser, -o nice specifiers" +//config: default y +//config: depends on PS && DESKTOP //applet:IF_PS(APPLET(ps, BB_DIR_BIN, BB_SUID_DROP)) diff --git a/procps/uptime.c b/procps/uptime.c index 436193925..8e8956c0f 100644 --- a/procps/uptime.c +++ b/procps/uptime.c @@ -21,11 +21,11 @@ //config: on, and the system load averages for the past 1, 5, and 15 minutes. //config: //config:config FEATURE_UPTIME_UTMP_SUPPORT -//config: bool "Support for showing the number of users" +//config: bool "Show the number of users" //config: default y //config: depends on UPTIME && FEATURE_UTMP //config: help -//config: Makes uptime display the number of users currently logged on. +//config: Display the number of users currently logged on. //applet:IF_UPTIME(APPLET(uptime, BB_DIR_USR_BIN, BB_SUID_DROP)) diff --git a/selinux/chcon.c b/selinux/chcon.c index c743013ce..4a9a4d3d5 100644 --- a/selinux/chcon.c +++ b/selinux/chcon.c @@ -18,8 +18,6 @@ //config: bool "Enable long options" //config: default y //config: depends on CHCON && LONG_OPTS -//config: help -//config: Support long options for the chcon applet. //applet:IF_CHCON(APPLET(chcon, BB_DIR_USR_BIN, BB_SUID_DROP)) diff --git a/selinux/runcon.c b/selinux/runcon.c index 16f171101..a30e3552f 100644 --- a/selinux/runcon.c +++ b/selinux/runcon.c @@ -39,8 +39,6 @@ //config: bool "Enable long options" //config: default y //config: depends on RUNCON && LONG_OPTS -//config: help -//config: Support long options for the runcon applet. //applet:IF_RUNCON(APPLET(runcon, BB_DIR_USR_BIN, BB_SUID_DROP)) diff --git a/shell/ash.c b/shell/ash.c index 9c46a93e0..20ed9652c 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -35,8 +35,6 @@ //config: bool "Optimize for size instead of speed" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH -//config: help -//config: Compile ash for reduced size at the price of speed. //config: //config:config ASH_INTERNAL_GLOB //config: bool "Use internal glob() implementation" @@ -46,6 +44,23 @@ //config: Do not use glob() function from libc, use internal implementation. //config: Use this if you are getting "glob.h: No such file or directory" //config: or similar build errors. +//config: Note that as of now (2017-01), uclibc and musl glob() both have bugs +//config: which would break ash if you select N here. +//config: +//config:config ASH_BASH_COMPAT +//config: bool "bash-compatible extensions" +//config: default y +//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH +//config: +//config:config ASH_JOB_CONTROL +//config: bool "Job control" +//config: default y +//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH +//config: +//config:config ASH_ALIAS +//config: bool "Alias support" +//config: default y +//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH //config: //config:config ASH_RANDOM_SUPPORT //config: bool "Pseudorandom generator and $RANDOM variable" @@ -63,88 +78,60 @@ //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH //config: help -//config: "PS#" may contain volatile content, such as backquote commands. +//config: $PS# may contain volatile content, such as backquote commands. //config: This option recreates the prompt string from the environment //config: variable each time it is displayed. //config: -//config:config ASH_BASH_COMPAT -//config: bool "bash-compatible extensions" -//config: default y -//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH -//config: help -//config: Enable bash-compatible extensions. -//config: //config:config ASH_IDLE_TIMEOUT -//config: bool "Idle timeout variable" -//config: default n -//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH -//config: help -//config: Enables bash-like auto-logout after $TMOUT seconds of idle time. -//config: -//config:config ASH_JOB_CONTROL -//config: bool "Job control" -//config: default y -//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH -//config: help -//config: Enable job control in the ash shell. -//config: -//config:config ASH_ALIAS -//config: bool "Alias support" +//config: bool "Idle timeout variable $TMOUT" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH //config: help -//config: Enable alias support in the ash shell. +//config: Enable bash-like auto-logout after $TMOUT seconds of idle time. //config: -//config:config ASH_GETOPTS -//config: bool "Builtin getopt to parse positional parameters" +//config:config ASH_MAIL +//config: bool "Check for new mail in interactive shell" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH //config: help -//config: Enable support for getopts builtin in ash. +//config: Enable "check for new mail" function: +//config: if set, $MAIL file and $MAILPATH list of files +//config: are checked for mtime changes, and "you have mail" +//config: message is printed if change is detected. //config: //config:config ASH_BUILTIN_ECHO -//config: bool "Builtin version of 'echo'" +//config: bool "echo builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH -//config: help -//config: Enable support for echo builtin in ash. //config: //config:config ASH_BUILTIN_PRINTF -//config: bool "Builtin version of 'printf'" +//config: bool "printf builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH -//config: help -//config: Enable support for printf builtin in ash. //config: //config:config ASH_BUILTIN_TEST -//config: bool "Builtin version of 'test'" +//config: bool "test builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH -//config: help -//config: Enable support for test builtin in ash. //config: //config:config ASH_HELP //config: bool "help builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH -//config: help -//config: Enable help builtin in ash. //config: -//config:config ASH_CMDCMD -//config: bool "'command' command to override shell builtins" +//config:config ASH_GETOPTS +//config: bool "getopts builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH -//config: help -//config: Enable support for the ash 'command' builtin, which allows -//config: you to run the specified command with the specified arguments, -//config: even when there is an ash builtin command with the same name. //config: -//config:config ASH_MAIL -//config: bool "Check for new mail on interactive shells" +//config:config ASH_CMDCMD +//config: bool "command builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH //config: help -//config: Enable "check for new mail" function in the ash shell. +//config: Enable support for the 'command' builtin, which allows +//config: you to run the specified command or builtin, +//config: even when there is a function with the same name. //config: //config:endif # ash options diff --git a/shell/hush.c b/shell/hush.c index 22d71cb07..9e508fc6d 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -99,8 +99,6 @@ //config: bool "bash-compatible extensions" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable bash-compatible extensions. //config: //config:config HUSH_BRACE_EXPANSION //config: bool "Brace expansion" @@ -123,8 +121,6 @@ //config: bool "Save command history to .hush_history" //config: default y //config: depends on HUSH_INTERACTIVE && FEATURE_EDITING_SAVEHISTORY -//config: help -//config: Enable history saving in hush. //config: //config:config HUSH_JOB //config: bool "Job control" @@ -138,39 +134,35 @@ //config: but no separate process group is formed. //config: //config:config HUSH_TICK -//config: bool "Process substitution" +//config: bool "Support process substitution" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: help -//config: Enable process substitution `command` and $(command) in hush. +//config: Enable `command` and $(command). //config: //config:config HUSH_IF //config: bool "Support if/then/elif/else/fi" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable if/then/elif/else/fi in hush. //config: //config:config HUSH_LOOPS //config: bool "Support for, while and until loops" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable for, while and until loops in hush. //config: //config:config HUSH_CASE //config: bool "Support case ... esac statement" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: help -//config: Enable case ... esac statement in hush. +400 bytes. +//config: Enable case ... esac statement. +400 bytes. //config: //config:config HUSH_FUNCTIONS //config: bool "Support funcname() { commands; } syntax" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: help -//config: Enable support for shell functions in hush. +800 bytes. +//config: Enable support for shell functions. +800 bytes. //config: //config:config HUSH_LOCAL //config: bool "local builtin" @@ -199,22 +191,21 @@ //config: bool "echo builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable echo builtin in hush. //config: //config:config HUSH_PRINTF //config: bool "printf builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable printf builtin in hush. +//config: +//config:config HUSH_HELP +//config: bool "help builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: //config:config HUSH_EXPORT //config: bool "export builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable export builtin in hush. //config: //config:config HUSH_EXPORT_N //config: bool "Support 'export -n' option" @@ -223,82 +214,55 @@ //config: help //config: export -n unexports variables. It is a bash extension. //config: -//config:config HUSH_HELP -//config: bool "help builtin" -//config: default y -//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable help builtin in hush. Code size + ~1 kbyte. -//config: //config:config HUSH_KILL -//config: bool "kill builtin (for kill %jobspec)" +//config: bool "kill builtin (supports kill %jobspec)" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable kill builtin in hush. //config: //config:config HUSH_WAIT //config: bool "wait builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable wait builtin in hush. //config: //config:config HUSH_TRAP //config: bool "trap builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable trap builtin in hush. -//config: -//config:config HUSH_ULIMIT -//config: bool "ulimit builtin" -//config: default y -//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable ulimit builtin in hush. //config: //config:config HUSH_TYPE //config: bool "type builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable type builtin in hush. //config: //config:config HUSH_READ //config: bool "read builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable read builtin in hush. //config: //config:config HUSH_SET //config: bool "set builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable set builtin in hush. //config: //config:config HUSH_UNSET //config: bool "unset builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable unset builtin in hush. +//config: +//config:config HUSH_ULIMIT +//config: bool "ulimit builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: //config:config HUSH_UMASK //config: bool "umask builtin" //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable umask builtin in hush. //config: //config:config HUSH_MEMLEAK //config: bool "memleak builtin (debugging)" //config: default n //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH -//config: help -//config: Enable memleak builtin in hush. //config: //config:config MSH //config: bool "msh (deprecated: aliased to hush)" @@ -1096,8 +1060,6 @@ static const struct built_in_command bltins1[] = { BLTIN("wait" , builtin_wait , "Wait for process"), #endif }; -/* For now, echo and test are unconditionally enabled. - * Maybe make it configurable? */ static const struct built_in_command bltins2[] = { BLTIN("[" , builtin_test , NULL), #if ENABLE_HUSH_ECHO diff --git a/util-linux/Config.src b/util-linux/Config.src index 3c522f948..0971d714a 100644 --- a/util-linux/Config.src +++ b/util-linux/Config.src @@ -40,7 +40,7 @@ config FEATURE_MOUNT_LOOP_CREATE if it does not find a free one. config FEATURE_MTAB_SUPPORT - bool "Support for the old /etc/mtab file" + bool "Support old /etc/mtab file" default n depends on MOUNT || UMOUNT select FEATURE_MOUNT_FAKE diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index b7b2c6924..c3574f8f5 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c @@ -22,7 +22,7 @@ //config: wish to enable the 'dmesg' utility. //config: //config:config FEATURE_DMESG_PRETTY -//config: bool "Pretty dmesg output" +//config: bool "Pretty output" //config: default y //config: depends on DMESG //config: help diff --git a/util-linux/fbset.c b/util-linux/fbset.c index 8a78c1ef9..673bf9aa4 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c @@ -22,7 +22,7 @@ //config: if you wish to enable the 'fbset' utility. //config: //config:config FEATURE_FBSET_FANCY -//config: bool "Turn on extra fbset options" +//config: bool "Enable extra options" //config: default y //config: depends on FBSET //config: help @@ -32,7 +32,7 @@ //config: options. //config: //config:config FEATURE_FBSET_READMODE -//config: bool "Turn on fbset readmode support" +//config: bool "Enable readmode support" //config: default y //config: depends on FBSET //config: help diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index b988e65a9..54f37baa6 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c @@ -21,8 +21,6 @@ //config: default y //config: depends on FDISK //config: depends on !LFS # with LFS no special code is needed -//config: help -//config: Enable this option to support large disks > 4GB. //config: //config:config FEATURE_FDISK_WRITABLE //config: bool "Write support" diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 084a7f1e9..d65011a71 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -20,10 +20,6 @@ //config: bool "Support long options (--hctosys,...)" //config: default y //config: depends on HWCLOCK && LONG_OPTS -//config: help -//config: By default, the hwclock utility only uses short options. If you -//config: are overly fond of its long options, such as --hctosys, --utc, etc) -//config: then enable this option. //config: //config:config FEATURE_HWCLOCK_ADJTIME_FHS //config: bool "Use FHS /var/lib/hwclock/adjtime" diff --git a/util-linux/mount.c b/util-linux/mount.c index 42962b859..4f5dced10 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -90,7 +90,7 @@ //config: //config:config FEATURE_MOUNT_FLAGS //config: depends on MOUNT -//config: bool "Support lots of -o flags in mount" +//config: bool "Support lots of -o flags" //config: default y //config: help //config: Without this, mount only supports ro/rw/remount. With this, it diff --git a/util-linux/volume_id/bcache.c b/util-linux/volume_id/bcache.c index fd40eb081..334a341c3 100644 --- a/util-linux/volume_id/bcache.c +++ b/util-linux/volume_id/bcache.c @@ -10,14 +10,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_BCACHE) += bcache.o -//config: //config:config FEATURE_VOLUMEID_BCACHE //config: bool "bcache filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/btrfs.c b/util-linux/volume_id/btrfs.c index e4dddf26d..338a48762 100644 --- a/util-linux/volume_id/btrfs.c +++ b/util-linux/volume_id/btrfs.c @@ -21,14 +21,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_BTRFS) += btrfs.o -//config: //config:config FEATURE_VOLUMEID_BTRFS //config: bool "btrfs filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/cramfs.c b/util-linux/volume_id/cramfs.c index aeb7f20ac..c63223e2b 100644 --- a/util-linux/volume_id/cramfs.c +++ b/util-linux/volume_id/cramfs.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_CRAMFS) += cramfs.o -//config: //config:config FEATURE_VOLUMEID_CRAMFS //config: bool "cramfs filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/exfat.c b/util-linux/volume_id/exfat.c index c3aa36804..7ed13a70e 100644 --- a/util-linux/volume_id/exfat.c +++ b/util-linux/volume_id/exfat.c @@ -20,7 +20,6 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXFAT) += exfat.o -//config: //config:config FEATURE_VOLUMEID_EXFAT //config: bool "exFAT filesystem" //config: default y @@ -29,7 +28,6 @@ //config: exFAT (extended FAT) is a proprietary file system designed especially //config: for flash drives. It has many features from NTFS, but with less //config: overhead. exFAT is used on most SDXC cards for consumer electronics. -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/ext.c b/util-linux/volume_id/ext.c index df39d9342..473b3229a 100644 --- a/util-linux/volume_id/ext.c +++ b/util-linux/volume_id/ext.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXT) += ext.o -//config: //config:config FEATURE_VOLUMEID_EXT //config: bool "Ext filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" #include "bb_e2fs_defs.h" diff --git a/util-linux/volume_id/f2fs.c b/util-linux/volume_id/f2fs.c index bf0b66278..1d3bdae36 100644 --- a/util-linux/volume_id/f2fs.c +++ b/util-linux/volume_id/f2fs.c @@ -8,7 +8,6 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_F2FS) += f2fs.o -//config: //config:config FEATURE_VOLUMEID_F2FS //config: bool "f2fs filesystem" //config: default y @@ -18,7 +17,6 @@ //config: which is adapted to newer forms of storage. F2FS also remedies some //config: known issues of the older log structured file systems, such as high //config: cleaning overhead. -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/fat.c b/util-linux/volume_id/fat.c index 476d500a6..bc3433daf 100644 --- a/util-linux/volume_id/fat.c +++ b/util-linux/volume_id/fat.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_FAT) += fat.o -//config: //config:config FEATURE_VOLUMEID_FAT //config: bool "fat filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/hfs.c b/util-linux/volume_id/hfs.c index 8d34aaf68..78dae0790 100644 --- a/util-linux/volume_id/hfs.c +++ b/util-linux/volume_id/hfs.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_HFS) += hfs.o -//config: //config:config FEATURE_VOLUMEID_HFS //config: bool "hfs filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/iso9660.c b/util-linux/volume_id/iso9660.c index 3848de453..23072f87c 100644 --- a/util-linux/volume_id/iso9660.c +++ b/util-linux/volume_id/iso9660.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ISO9660) += iso9660.o -//config: //config:config FEATURE_VOLUMEID_ISO9660 //config: bool "iso9660 filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/jfs.c b/util-linux/volume_id/jfs.c index a6eaff45b..543d90fe5 100644 --- a/util-linux/volume_id/jfs.c +++ b/util-linux/volume_id/jfs.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_JFS) += jfs.o -//config: //config:config FEATURE_VOLUMEID_JFS //config: bool "jfs filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/linux_raid.c b/util-linux/volume_id/linux_raid.c index f20823a6e..0db6e8662 100644 --- a/util-linux/volume_id/linux_raid.c +++ b/util-linux/volume_id/linux_raid.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o -//config: //config:config FEATURE_VOLUMEID_LINUXRAID //config: bool "linuxraid" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/linux_swap.c b/util-linux/volume_id/linux_swap.c index 39470d48c..a35769dfc 100644 --- a/util-linux/volume_id/linux_swap.c +++ b/util-linux/volume_id/linux_swap.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o -//config: //config:config FEATURE_VOLUMEID_LINUXSWAP //config: bool "linux swap filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/luks.c b/util-linux/volume_id/luks.c index 21cb26f51..4b80b7a6d 100644 --- a/util-linux/volume_id/luks.c +++ b/util-linux/volume_id/luks.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LUKS) += luks.o -//config: //config:config FEATURE_VOLUMEID_LUKS //config: bool "luks filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/nilfs.c b/util-linux/volume_id/nilfs.c index f3a9ef58d..ffe919f36 100644 --- a/util-linux/volume_id/nilfs.c +++ b/util-linux/volume_id/nilfs.c @@ -21,7 +21,6 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NILFS) += nilfs.o -//config: //config:config FEATURE_VOLUMEID_NILFS //config: bool "nilfs filesystem" //config: default y @@ -37,7 +36,6 @@ //config: SOX compliance logging, and so forth. It can serve as an alternative //config: filesystem for Linux desktop environment, or as a basis of advanced //config: storage appliances. -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/ntfs.c b/util-linux/volume_id/ntfs.c index 46f687a56..bf85f7ed3 100644 --- a/util-linux/volume_id/ntfs.c +++ b/util-linux/volume_id/ntfs.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o -//config: //config:config FEATURE_VOLUMEID_NTFS //config: bool "ntfs filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/ocfs2.c b/util-linux/volume_id/ocfs2.c index 415e0bf61..2dedac98b 100644 --- a/util-linux/volume_id/ocfs2.c +++ b/util-linux/volume_id/ocfs2.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_OCFS2) += ocfs2.o -//config: //config:config FEATURE_VOLUMEID_OCFS2 //config: bool "ocfs2 filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/reiserfs.c b/util-linux/volume_id/reiserfs.c index 24979fb1c..369d4d9bb 100644 --- a/util-linux/volume_id/reiserfs.c +++ b/util-linux/volume_id/reiserfs.c @@ -21,14 +21,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o -//config: //config:config FEATURE_VOLUMEID_REISERFS //config: bool "Reiser filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/romfs.c b/util-linux/volume_id/romfs.c index 4754fdb37..95a65f9ef 100644 --- a/util-linux/volume_id/romfs.c +++ b/util-linux/volume_id/romfs.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ROMFS) += romfs.o -//config: //config:config FEATURE_VOLUMEID_ROMFS //config: bool "romfs filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/squashfs.c b/util-linux/volume_id/squashfs.c index 079b6cc31..6bba199cd 100644 --- a/util-linux/volume_id/squashfs.c +++ b/util-linux/volume_id/squashfs.c @@ -8,7 +8,6 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SQUASHFS) += squashfs.o -//config: //config:config FEATURE_VOLUMEID_SQUASHFS //config: bool "SquashFS filesystem" //config: default y @@ -18,7 +17,6 @@ //config: intended for general read-only filesystem use and in constrained block //config: device/memory systems (e.g. embedded systems) where low overhead is //config: needed. -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/sysv.c b/util-linux/volume_id/sysv.c index 7b4b5360b..cd4cd906b 100644 --- a/util-linux/volume_id/sysv.c +++ b/util-linux/volume_id/sysv.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SYSV) += sysv.o -//config: //config:config FEATURE_VOLUMEID_SYSV //config: bool "sysv filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/ubifs.c b/util-linux/volume_id/ubifs.c index 13604ec35..99b0aa830 100644 --- a/util-linux/volume_id/ubifs.c +++ b/util-linux/volume_id/ubifs.c @@ -8,7 +8,6 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_UBIFS) += ubifs.o -//config: //config:config FEATURE_VOLUMEID_UBIFS //config: bool "UBIFS filesystem" //config: default y @@ -16,7 +15,6 @@ //config: help //config: UBIFS (Unsorted Block Image File System) is a file //config: system for use with raw flash memory media. -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/udf.c b/util-linux/volume_id/udf.c index 921454503..613c80c86 100644 --- a/util-linux/volume_id/udf.c +++ b/util-linux/volume_id/udf.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o -//config: //config:config FEATURE_VOLUMEID_UDF //config: bool "udf filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_highpoint.c b/util-linux/volume_id/unused_highpoint.c index 7231a1db2..4afa6d927 100644 --- a/util-linux/volume_id/unused_highpoint.c +++ b/util-linux/volume_id/unused_highpoint.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID) += highpoint.o -//config: //config:### config FEATURE_VOLUMEID_HIGHPOINTRAID //config:### bool "highpoint raid" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_hpfs.c b/util-linux/volume_id/unused_hpfs.c index a87c89fb3..3e16dedbd 100644 --- a/util-linux/volume_id/unused_hpfs.c +++ b/util-linux/volume_id/unused_hpfs.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HPFS) += hpfs.o -//config: //config:### config FEATURE_VOLUMEID_HPFS //config:### bool "hpfs filesystem" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_isw_raid.c b/util-linux/volume_id/unused_isw_raid.c index 851bd2f8f..fba99be58 100644 --- a/util-linux/volume_id/unused_isw_raid.c +++ b/util-linux/volume_id/unused_isw_raid.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_ISWRAID) += isw_raid.o -//config: //config:### config FEATURE_VOLUMEID_ISWRAID //config:### bool "intel raid" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_lsi_raid.c b/util-linux/volume_id/unused_lsi_raid.c index 52d68deab..9dd2b409c 100644 --- a/util-linux/volume_id/unused_lsi_raid.c +++ b/util-linux/volume_id/unused_lsi_raid.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LSIRAID) += lsi_raid.o -//config: //config:### config FEATURE_VOLUMEID_LSIRAID //config:### bool "lsi raid" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_lvm.c b/util-linux/volume_id/unused_lvm.c index 08fa05243..5ad6d585c 100644 --- a/util-linux/volume_id/unused_lvm.c +++ b/util-linux/volume_id/unused_lvm.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o -//config: //config:### config FEATURE_VOLUMEID_LVM //config:### bool "lvm" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_mac.c b/util-linux/volume_id/unused_mac.c index a1a53d1fb..997d330a4 100644 --- a/util-linux/volume_id/unused_mac.c +++ b/util-linux/volume_id/unused_mac.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o -//config: //config:### config FEATURE_VOLUMEID_MAC //config:### bool "mac filesystem" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_minix.c b/util-linux/volume_id/unused_minix.c index 50afd5c3e..443dbc272 100644 --- a/util-linux/volume_id/unused_minix.c +++ b/util-linux/volume_id/unused_minix.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MINIX) += minix.o -//config: //config:### config FEATURE_VOLUMEID_MINIX //config:### bool "minix filesystem" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_msdos.c b/util-linux/volume_id/unused_msdos.c index 5ebaa3eef..f84c0f06f 100644 --- a/util-linux/volume_id/unused_msdos.c +++ b/util-linux/volume_id/unused_msdos.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o -//config: //config:### config FEATURE_VOLUMEID_MSDOS //config:### bool "msdos filesystem" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_nvidia_raid.c b/util-linux/volume_id/unused_nvidia_raid.c index d99a108f3..dfb54fa9d 100644 --- a/util-linux/volume_id/unused_nvidia_raid.c +++ b/util-linux/volume_id/unused_nvidia_raid.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_NVIDIARAID) += nvidia_raid.o -//config: //config:### config FEATURE_VOLUMEID_NVIDIARAID //config:### bool "nvidia raid" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_promise_raid.c b/util-linux/volume_id/unused_promise_raid.c index cebebe35f..d594de39c 100644 --- a/util-linux/volume_id/unused_promise_raid.c +++ b/util-linux/volume_id/unused_promise_raid.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_PROMISERAID) += promise_raid.o -//config: //config:### config FEATURE_VOLUMEID_PROMISERAID //config:### bool "promise raid" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_silicon_raid.c b/util-linux/volume_id/unused_silicon_raid.c index 40c8faa9e..886721b61 100644 --- a/util-linux/volume_id/unused_silicon_raid.c +++ b/util-linux/volume_id/unused_silicon_raid.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_SILICONRAID) += silicon_raid.o -//config: //config:### config FEATURE_VOLUMEID_SILICONRAID //config:### bool "silicon raid" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_ufs.c b/util-linux/volume_id/unused_ufs.c index d33c10fc4..78ef26ad4 100644 --- a/util-linux/volume_id/unused_ufs.c +++ b/util-linux/volume_id/unused_ufs.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_UFS) += ufs.o -//config: //config:### config FEATURE_VOLUMEID_UFS //config:### bool "ufs filesystem" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/unused_via_raid.c b/util-linux/volume_id/unused_via_raid.c index 258f93a4f..f82626655 100644 --- a/util-linux/volume_id/unused_via_raid.c +++ b/util-linux/volume_id/unused_via_raid.c @@ -20,14 +20,10 @@ //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_VIARAID) += via_raid.o -//config: //config:### config FEATURE_VOLUMEID_VIARAID //config:### bool "via raid" //config:### default y //config:### depends on VOLUMEID -//config:### help -//config:### TODO -//config: #include "volume_id_internal.h" diff --git a/util-linux/volume_id/xfs.c b/util-linux/volume_id/xfs.c index 5eefc201d..656d5bfcf 100644 --- a/util-linux/volume_id/xfs.c +++ b/util-linux/volume_id/xfs.c @@ -20,14 +20,10 @@ //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_XFS) += xfs.o -//config: //config:config FEATURE_VOLUMEID_XFS //config: bool "xfs filesystem" //config: default y //config: depends on VOLUMEID -//config: help -//config: TODO -//config: #include "volume_id_internal.h" -- cgit v1.2.3-55-g6feb From 265062d59dd46065ad34519f04615fb2cecefe8a Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 10 Jan 2017 15:13:30 +0100 Subject: shells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_foo This makes hash and ash more symmetrical wrt config menu and config options. Signed-off-by: Denys Vlasenko --- configs/TEST_nommu_defconfig | 6 +++--- configs/TEST_noprintf_defconfig | 6 +++--- configs/TEST_rh9_defconfig | 6 +++--- configs/android2_defconfig | 6 +++--- configs/android_502_defconfig | 6 +++--- configs/android_defconfig | 6 +++--- configs/android_ndk_defconfig | 6 +++--- configs/cygwin_defconfig | 6 +++--- configs/freebsd_defconfig | 6 +++--- coreutils/Kbuild.src | 6 ------ coreutils/echo.c | 5 ++++- coreutils/printf.c | 5 ++++- coreutils/test.c | 17 ++++++++--------- shell/ash.c | 26 +++++++++++++------------- shell/hush.c | 16 +++++++++++++++- testsuite/mdev.tests | 2 +- 16 files changed, 72 insertions(+), 59 deletions(-) (limited to 'shell') diff --git a/configs/TEST_nommu_defconfig b/configs/TEST_nommu_defconfig index 08351a294..d9ec41cd0 100644 --- a/configs/TEST_nommu_defconfig +++ b/configs/TEST_nommu_defconfig @@ -879,9 +879,9 @@ CONFIG_FEATURE_SH_IS_HUSH=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/configs/TEST_noprintf_defconfig b/configs/TEST_noprintf_defconfig index 70dacece0..c7330ed5d 100644 --- a/configs/TEST_noprintf_defconfig +++ b/configs/TEST_noprintf_defconfig @@ -873,9 +873,9 @@ CONFIG_SV_DEFAULT_SERVICE_DIR="" # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/configs/TEST_rh9_defconfig b/configs/TEST_rh9_defconfig index 4a5fad324..86e13cd53 100644 --- a/configs/TEST_rh9_defconfig +++ b/configs/TEST_rh9_defconfig @@ -893,9 +893,9 @@ CONFIG_ASH_BASH_COMPAT=y CONFIG_ASH_JOB_CONTROL=y CONFIG_ASH_ALIAS=y CONFIG_ASH_GETOPTS=y -CONFIG_ASH_BUILTIN_ECHO=y -CONFIG_ASH_BUILTIN_PRINTF=y -CONFIG_ASH_BUILTIN_TEST=y +CONFIG_ASH_ECHO=y +CONFIG_ASH_PRINTF=y +CONFIG_ASH_TEST=y CONFIG_ASH_CMDCMD=y # CONFIG_ASH_MAIL is not set CONFIG_ASH_OPTIMIZE_FOR_SIZE=y diff --git a/configs/android2_defconfig b/configs/android2_defconfig index 754f612c6..9338f66ac 100644 --- a/configs/android2_defconfig +++ b/configs/android2_defconfig @@ -936,9 +936,9 @@ CONFIG_SOFTLIMIT=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/configs/android_502_defconfig b/configs/android_502_defconfig index 8ea6c295d..316063440 100644 --- a/configs/android_502_defconfig +++ b/configs/android_502_defconfig @@ -1081,9 +1081,9 @@ CONFIG_ASH_BASH_COMPAT=y CONFIG_ASH_JOB_CONTROL=y CONFIG_ASH_ALIAS=y CONFIG_ASH_GETOPTS=y -CONFIG_ASH_BUILTIN_ECHO=y -CONFIG_ASH_BUILTIN_PRINTF=y -CONFIG_ASH_BUILTIN_TEST=y +CONFIG_ASH_ECHO=y +CONFIG_ASH_PRINTF=y +CONFIG_ASH_TEST=y CONFIG_ASH_HELP=y CONFIG_ASH_CMDCMD=y # CONFIG_ASH_MAIL is not set diff --git a/configs/android_defconfig b/configs/android_defconfig index 30e888ac7..cd3490c4e 100644 --- a/configs/android_defconfig +++ b/configs/android_defconfig @@ -968,9 +968,9 @@ CONFIG_SOFTLIMIT=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/configs/android_ndk_defconfig b/configs/android_ndk_defconfig index 716ec9a5d..f2773be46 100644 --- a/configs/android_ndk_defconfig +++ b/configs/android_ndk_defconfig @@ -996,9 +996,9 @@ CONFIG_SOFTLIMIT=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_HELP is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set diff --git a/configs/cygwin_defconfig b/configs/cygwin_defconfig index b856482f6..816f76e65 100644 --- a/configs/cygwin_defconfig +++ b/configs/cygwin_defconfig @@ -936,9 +936,9 @@ CONFIG_ASH_BASH_COMPAT=y CONFIG_ASH_JOB_CONTROL=y CONFIG_ASH_ALIAS=y CONFIG_ASH_GETOPTS=y -CONFIG_ASH_BUILTIN_ECHO=y -CONFIG_ASH_BUILTIN_PRINTF=y -CONFIG_ASH_BUILTIN_TEST=y +CONFIG_ASH_ECHO=y +CONFIG_ASH_PRINTF=y +CONFIG_ASH_TEST=y CONFIG_ASH_CMDCMD=y # CONFIG_ASH_MAIL is not set CONFIG_ASH_OPTIMIZE_FOR_SIZE=y diff --git a/configs/freebsd_defconfig b/configs/freebsd_defconfig index 4f14d3be9..d223b7230 100644 --- a/configs/freebsd_defconfig +++ b/configs/freebsd_defconfig @@ -912,9 +912,9 @@ CONFIG_ASH=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/coreutils/Kbuild.src b/coreutils/Kbuild.src index d0b3f629b..a805b64fe 100644 --- a/coreutils/Kbuild.src +++ b/coreutils/Kbuild.src @@ -16,9 +16,3 @@ lib-$(CONFIG_CRONTAB) += cat.o # crontab -l lib-$(CONFIG_ADDUSER) += chown.o # used by adduser lib-$(CONFIG_ADDGROUP) += chown.o # used by addgroup lib-$(CONFIG_FTPD) += ls.o # used by ftpd - -lib-$(CONFIG_ASH_BUILTIN_ECHO) += echo.o -lib-$(CONFIG_HUSH_ECHO) += echo.o - -lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o -lib-$(CONFIG_HUSH_PRINTF) += printf.o diff --git a/coreutils/echo.c b/coreutils/echo.c index d0dba650d..a7e4ca9ac 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c @@ -28,12 +28,15 @@ //config:config FEATURE_FANCY_ECHO //config: bool "Enable -n and -e options" //config: default y -//config: depends on ECHO || ASH_BUILTIN_ECHO || HUSH_ECHO +//config: depends on ECHO || ASH_ECHO || HUSH_ECHO //applet:IF_ECHO(APPLET_NOFORK(echo, echo, BB_DIR_BIN, BB_SUID_DROP, echo)) //kbuild:lib-$(CONFIG_ECHO) += echo.o +//kbuild:lib-$(CONFIG_ASH_ECHO) += echo.o +//kbuild:lib-$(CONFIG_HUSH_ECHO) += echo.o + /* BB_AUDIT SUSv3 compliant -- unless configured as fancy echo. */ /* http://www.opengroup.org/onlinepubs/007904975/utilities/echo.html */ diff --git a/coreutils/printf.c b/coreutils/printf.c index 6c8e115d8..bc22e0ee7 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c @@ -49,6 +49,9 @@ //kbuild:lib-$(CONFIG_PRINTF) += printf.o +//kbuild:lib-$(CONFIG_ASH_PRINTF) += printf.o +//kbuild:lib-$(CONFIG_HUSH_PRINTF) += printf.o + //usage:#define printf_trivial_usage //usage: "FORMAT [ARG]..." //usage:#define printf_full_usage "\n\n" @@ -417,7 +420,7 @@ int printf_main(int argc UNUSED_PARAM, char **argv) if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && !argv[1][2]) argv++; if (!argv[1]) { - if (ENABLE_ASH_BUILTIN_PRINTF + if (ENABLE_ASH_PRINTF && applet_name[0] != 'p' ) { bb_error_msg("usage: printf FORMAT [ARGUMENT...]"); diff --git a/coreutils/test.c b/coreutils/test.c index 288f66508..edc625f57 100644 --- a/coreutils/test.c +++ b/coreutils/test.c @@ -42,21 +42,20 @@ //config:config FEATURE_TEST_64 //config: bool "Extend test to 64 bit" //config: default y -//config: depends on TEST || TEST1 || TEST2 || ASH_BUILTIN_TEST || HUSH +//config: depends on TEST || TEST1 || TEST2 || ASH_TEST || HUSH_TEST //config: help //config: Enable 64-bit support in test. //applet:IF_TEST(APPLET_NOFORK(test, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) -//applet:IF_TEST1(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) -//applet:IF_TEST2(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) +//applet:IF_TEST1(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) +//applet:IF_TEST2(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) -//kbuild:lib-$(CONFIG_TEST) += test.o test_ptr_hack.o +//kbuild:lib-$(CONFIG_TEST) += test.o test_ptr_hack.o //kbuild:lib-$(CONFIG_TEST1) += test.o test_ptr_hack.o //kbuild:lib-$(CONFIG_TEST2) += test.o test_ptr_hack.o -//kbuild:lib-$(CONFIG_ASH_BUILTIN_TEST) += test.o test_ptr_hack.o -//kbuild:lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o -//kbuild:lib-$(CONFIG_SH_IS_HUSH) += test.o test_ptr_hack.o -//kbuild:lib-$(CONFIG_BASH_IS_HUSH) += test.o test_ptr_hack.o + +//kbuild:lib-$(CONFIG_ASH_TEST) += test.o test_ptr_hack.o +//kbuild:lib-$(CONFIG_HUSH_TEST) += test.o test_ptr_hack.o /* "test --help" is special-cased to ignore --help */ //usage:#define test_trivial_usage NOUSAGE_STR @@ -843,7 +842,7 @@ int test_main(int argc, char **argv) const char *arg0; arg0 = bb_basename(argv[0]); - if ((ENABLE_TEST1 || ENABLE_TEST2 || ENABLE_ASH_BUILTIN_TEST || ENABLE_HUSH) + if ((ENABLE_TEST1 || ENABLE_TEST2 || ENABLE_ASH_TEST || ENABLE_HUSH_TEST) && (arg0[0] == '[') ) { --argc; diff --git a/shell/ash.c b/shell/ash.c index 20ed9652c..7c1204a47 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -99,17 +99,17 @@ //config: are checked for mtime changes, and "you have mail" //config: message is printed if change is detected. //config: -//config:config ASH_BUILTIN_ECHO +//config:config ASH_ECHO //config: bool "echo builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH //config: -//config:config ASH_BUILTIN_PRINTF +//config:config ASH_PRINTF //config: bool "printf builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH //config: -//config:config ASH_BUILTIN_TEST +//config:config ASH_TEST //config: bool "test builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH @@ -9292,13 +9292,13 @@ static int ulimitcmd(int, char **) FAST_FUNC; #define BUILTIN_SPEC_REG_ASSG "7" /* Stubs for calling non-FAST_FUNC's */ -#if ENABLE_ASH_BUILTIN_ECHO +#if ENABLE_ASH_ECHO static int FAST_FUNC echocmd(int argc, char **argv) { return echo_main(argc, argv); } #endif -#if ENABLE_ASH_BUILTIN_PRINTF +#if ENABLE_ASH_PRINTF static int FAST_FUNC printfcmd(int argc, char **argv) { return printf_main(argc, argv); } #endif -#if ENABLE_ASH_BUILTIN_TEST +#if ENABLE_ASH_TEST static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, argv); } #endif @@ -9306,7 +9306,7 @@ static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, a static const struct builtincmd builtintab[] = { { BUILTIN_SPEC_REG "." , dotcmd }, { BUILTIN_SPEC_REG ":" , truecmd }, -#if ENABLE_ASH_BUILTIN_TEST +#if ENABLE_ASH_TEST { BUILTIN_REGULAR "[" , testcmd }, # if ENABLE_ASH_BASH_COMPAT { BUILTIN_REGULAR "[[" , testcmd }, @@ -9325,7 +9325,7 @@ static const struct builtincmd builtintab[] = { { BUILTIN_REGULAR "command" , commandcmd }, #endif { BUILTIN_SPEC_REG "continue", breakcmd }, -#if ENABLE_ASH_BUILTIN_ECHO +#if ENABLE_ASH_ECHO { BUILTIN_REGULAR "echo" , echocmd }, #endif { BUILTIN_SPEC_REG "eval" , NULL }, /*evalcmd() has a differing prototype*/ @@ -9354,7 +9354,7 @@ static const struct builtincmd builtintab[] = { { BUILTIN_NOSPEC "let" , letcmd }, #endif { BUILTIN_ASSIGN "local" , localcmd }, -#if ENABLE_ASH_BUILTIN_PRINTF +#if ENABLE_ASH_PRINTF { BUILTIN_REGULAR "printf" , printfcmd }, #endif { BUILTIN_NOSPEC "pwd" , pwdcmd }, @@ -9366,7 +9366,7 @@ static const struct builtincmd builtintab[] = { #if ENABLE_ASH_BASH_COMPAT { BUILTIN_SPEC_REG "source" , dotcmd }, #endif -#if ENABLE_ASH_BUILTIN_TEST +#if ENABLE_ASH_TEST { BUILTIN_REGULAR "test" , testcmd }, #endif { BUILTIN_SPEC_REG "times" , timescmd }, @@ -9385,15 +9385,15 @@ static const struct builtincmd builtintab[] = { /* Should match the above table! */ #define COMMANDCMD (builtintab + \ /* . : */ 2 + \ - /* [ */ 1 * ENABLE_ASH_BUILTIN_TEST + \ - /* [[ */ 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \ + /* [ */ 1 * ENABLE_ASH_TEST + \ + /* [[ */ 1 * ENABLE_ASH_TEST * ENABLE_ASH_BASH_COMPAT + \ /* alias */ 1 * ENABLE_ASH_ALIAS + \ /* bg */ 1 * ENABLE_ASH_JOB_CONTROL + \ /* break cd cddir */ 3) #define EVALCMD (COMMANDCMD + \ /* command */ 1 * ENABLE_ASH_CMDCMD + \ /* continue */ 1 + \ - /* echo */ 1 * ENABLE_ASH_BUILTIN_ECHO + \ + /* echo */ 1 * ENABLE_ASH_ECHO + \ 0) #define EXECCMD (EVALCMD + \ /* eval */ 1) diff --git a/shell/hush.c b/shell/hush.c index 9e508fc6d..c0325cf5e 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -197,6 +197,11 @@ //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: +//config:config HUSH_TEST +//config: bool "test builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: //config:config HUSH_HELP //config: bool "help builtin" //config: default y @@ -942,7 +947,9 @@ static int builtin_set(char **argv) FAST_FUNC; #endif static int builtin_shift(char **argv) FAST_FUNC; static int builtin_source(char **argv) FAST_FUNC; +#if ENABLE_HUSH_TEST static int builtin_test(char **argv) FAST_FUNC; +#endif #if ENABLE_HUSH_TRAP static int builtin_trap(char **argv) FAST_FUNC; #endif @@ -1061,7 +1068,9 @@ static const struct built_in_command bltins1[] = { #endif }; static const struct built_in_command bltins2[] = { +#if ENABLE_HUSH_TEST BLTIN("[" , builtin_test , NULL), +#endif #if ENABLE_HUSH_ECHO BLTIN("echo" , builtin_echo , NULL), #endif @@ -1069,7 +1078,9 @@ static const struct built_in_command bltins2[] = { BLTIN("printf" , builtin_printf , NULL), #endif BLTIN("pwd" , builtin_pwd , NULL), +#if ENABLE_HUSH_TEST BLTIN("test" , builtin_test , NULL), +#endif }; @@ -8791,6 +8802,7 @@ static int FAST_FUNC builtin_true(char **argv UNUSED_PARAM) return 0; } +#if ENABLE_HUSH_TEST || ENABLE_HUSH_ECHO || ENABLE_HUSH_PRINTF || ENABLE_HUSH_KILL static int run_applet_main(char **argv, int (*applet_main_func)(int argc, char **argv)) { int argc = 0; @@ -8800,11 +8812,13 @@ static int run_applet_main(char **argv, int (*applet_main_func)(int argc, char * } return applet_main_func(argc, argv - argc); } - +#endif +#if ENABLE_HUSH_TEST static int FAST_FUNC builtin_test(char **argv) { return run_applet_main(argv, test_main); } +#endif #if ENABLE_HUSH_ECHO static int FAST_FUNC builtin_echo(char **argv) { diff --git a/testsuite/mdev.tests b/testsuite/mdev.tests index 59873011a..8515aff31 100755 --- a/testsuite/mdev.tests +++ b/testsuite/mdev.tests @@ -168,7 +168,7 @@ SKIP= # continuing to use directory structure from prev test rm -rf mdev.testdir/dev/* echo "sda 0:0 644 @echo @echo TEST" >mdev.testdir/etc/mdev.conf -optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_SH_IS_ASH ASH_BUILTIN_ECHO +optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_SH_IS_ASH ASH_ECHO testing "mdev command" \ "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; ls -lnR mdev.testdir/dev | $FILTER_LS" \ -- cgit v1.2.3-55-g6feb From 2b4c258e74d033b75b7f34bb384290eceb5da8a6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 10 Jan 2017 15:18:38 +0100 Subject: ash: revert "make dot command search current directory first" Reverts this: commit 8ad78e1ec7b2e873953f9f476fb63b5893526c39 Author: Denis Vlasenko Date: Sun Feb 15 12:40:30 2009 +0000 ash: make dot command search current directory first, as bash does. Signed-off-by: Denys Vlasenko --- shell/ash.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 7c1204a47..866c7de05 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12502,16 +12502,7 @@ find_dot_file(char *name) if (strchr(name, '/')) return name; - /* IIRC standards do not say whether . is to be searched. - * And it is even smaller this way, making it unconditional for now: - */ - if (1) { /* ENABLE_ASH_BASH_COMPAT */ - fullname = name; - goto try_cur_dir; - } - while ((fullname = path_advance(&path, name)) != NULL) { - try_cur_dir: if ((stat(fullname, &statb) == 0) && S_ISREG(statb.st_mode)) { /* * Don't bother freeing here, since it will -- cgit v1.2.3-55-g6feb From a1184af5f87b82df34af7782f76df9a1041200f1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 10 Jan 2017 15:58:02 +0100 Subject: hush: reorder builtins (cd and pwd ought to be close, etc), no code changes Signed-off-by: Denys Vlasenko --- shell/hush.c | 602 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 300 insertions(+), 302 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index c0325cf5e..7cce89183 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -8832,6 +8832,30 @@ static int FAST_FUNC builtin_printf(char **argv) } #endif +#if ENABLE_HUSH_HELP +static int FAST_FUNC builtin_help(char **argv UNUSED_PARAM) +{ + const struct built_in_command *x; + + printf( + "Built-in commands:\n" + "------------------\n"); + for (x = bltins1; x != &bltins1[ARRAY_SIZE(bltins1)]; x++) { + if (x->b_descr) + printf("%-10s%s\n", x->b_cmd, x->b_descr); + } + return EXIT_SUCCESS; +} +#endif + +#if MAX_HISTORY && ENABLE_FEATURE_EDITING +static int FAST_FUNC builtin_history(char **argv UNUSED_PARAM) +{ + show_history(G.line_input_state); + return EXIT_SUCCESS; +} +#endif + static char **skip_dash_dash(char **argv) { argv++; @@ -8840,24 +8864,6 @@ static char **skip_dash_dash(char **argv) return argv; } -static int FAST_FUNC builtin_eval(char **argv) -{ - int rcode = EXIT_SUCCESS; - - argv = skip_dash_dash(argv); - if (*argv) { - char *str = expand_strvec_to_string(argv); - /* bash: - * eval "echo Hi; done" ("done" is syntax error): - * "echo Hi" will not execute too. - */ - parse_and_run_string(str); - free(str); - rcode = G.last_exitcode; - } - return rcode; -} - static int FAST_FUNC builtin_cd(char **argv) { const char *newdir; @@ -8885,6 +8891,30 @@ static int FAST_FUNC builtin_cd(char **argv) return EXIT_SUCCESS; } +static int FAST_FUNC builtin_pwd(char **argv UNUSED_PARAM) +{ + puts(get_cwd(0)); + return EXIT_SUCCESS; +} + +static int FAST_FUNC builtin_eval(char **argv) +{ + int rcode = EXIT_SUCCESS; + + argv = skip_dash_dash(argv); + if (*argv) { + char *str = expand_strvec_to_string(argv); + /* bash: + * eval "echo Hi; done" ("done" is syntax error): + * "echo Hi" will not execute too. + */ + parse_and_run_string(str); + free(str); + rcode = G.last_exitcode; + } + return rcode; +} + static int FAST_FUNC builtin_exec(char **argv) { argv = skip_dash_dash(argv); @@ -8930,6 +8960,147 @@ static int FAST_FUNC builtin_exit(char **argv) hush_exit(xatoi(argv[0]) & 0xff); } +#if ENABLE_HUSH_TYPE +/* http://www.opengroup.org/onlinepubs/9699919799/utilities/type.html */ +static int FAST_FUNC builtin_type(char **argv) +{ + int ret = EXIT_SUCCESS; + + while (*++argv) { + const char *type; + char *path = NULL; + + if (0) {} /* make conditional compile easier below */ + /*else if (find_alias(*argv)) + type = "an alias";*/ +#if ENABLE_HUSH_FUNCTIONS + else if (find_function(*argv)) + type = "a function"; +#endif + else if (find_builtin(*argv)) + type = "a shell builtin"; + else if ((path = find_in_path(*argv)) != NULL) + type = path; + else { + bb_error_msg("type: %s: not found", *argv); + ret = EXIT_FAILURE; + continue; + } + + printf("%s is %s\n", *argv, type); + free(path); + } + + return ret; +} +#endif + +#if ENABLE_HUSH_READ +/* Interruptibility of read builtin in bash + * (tested on bash-4.2.8 by sending signals (not by ^C)): + * + * Empty trap makes read ignore corresponding signal, for any signal. + * + * SIGINT: + * - terminates non-interactive shell; + * - interrupts read in interactive shell; + * if it has non-empty trap: + * - executes trap and returns to command prompt in interactive shell; + * - executes trap and returns to read in non-interactive shell; + * SIGTERM: + * - is ignored (does not interrupt) read in interactive shell; + * - terminates non-interactive shell; + * if it has non-empty trap: + * - executes trap and returns to read; + * SIGHUP: + * - terminates shell (regardless of interactivity); + * if it has non-empty trap: + * - executes trap and returns to read; + */ +static int FAST_FUNC builtin_read(char **argv) +{ + const char *r; + char *opt_n = NULL; + char *opt_p = NULL; + char *opt_t = NULL; + char *opt_u = NULL; + const char *ifs; + int read_flags; + + /* "!": do not abort on errors. + * Option string must start with "sr" to match BUILTIN_READ_xxx + */ + read_flags = getopt32(argv, "!srn:p:t:u:", &opt_n, &opt_p, &opt_t, &opt_u); + if (read_flags == (uint32_t)-1) + return EXIT_FAILURE; + argv += optind; + ifs = get_local_var_value("IFS"); /* can be NULL */ + + again: + r = shell_builtin_read(set_local_var_from_halves, + argv, + ifs, + read_flags, + opt_n, + opt_p, + opt_t, + opt_u + ); + + if ((uintptr_t)r == 1 && errno == EINTR) { + unsigned sig = check_and_run_traps(); + if (sig && sig != SIGINT) + goto again; + } + + if ((uintptr_t)r > 1) { + bb_error_msg("%s", r); + r = (char*)(uintptr_t)1; + } + + return (uintptr_t)r; +} +#endif + +#if ENABLE_HUSH_UMASK +static int FAST_FUNC builtin_umask(char **argv) +{ + int rc; + mode_t mask; + + rc = 1; + mask = umask(0); + argv = skip_dash_dash(argv); + if (argv[0]) { + mode_t old_mask = mask; + + /* numeric umasks are taken as-is */ + /* symbolic umasks are inverted: "umask a=rx" calls umask(222) */ + if (!isdigit(argv[0][0])) + mask ^= 0777; + mask = bb_parse_mode(argv[0], mask); + if (!isdigit(argv[0][0])) + mask ^= 0777; + if ((unsigned)mask > 0777) { + mask = old_mask; + /* bash messages: + * bash: umask: 'q': invalid symbolic mode operator + * bash: umask: 999: octal number out of range + */ + bb_error_msg("%s: invalid mode '%s'", "umask", argv[0]); + rc = 0; + } + } else { + /* Mimic bash */ + printf("%04o\n", (unsigned) mask); + /* fall through and restore mask which we set to 0 */ + } + umask(mask); + + return !rc; /* rc != 0 - success */ +} +#endif + #if ENABLE_HUSH_EXPORT || ENABLE_HUSH_TRAP static void print_escaped(const char *s) { @@ -9218,72 +9389,60 @@ static int FAST_FUNC builtin_shift(char **argv) return EXIT_FAILURE; } -#if ENABLE_HUSH_READ -/* Interruptibility of read builtin in bash - * (tested on bash-4.2.8 by sending signals (not by ^C)): - * - * Empty trap makes read ignore corresponding signal, for any signal. - * - * SIGINT: - * - terminates non-interactive shell; - * - interrupts read in interactive shell; - * if it has non-empty trap: - * - executes trap and returns to command prompt in interactive shell; - * - executes trap and returns to read in non-interactive shell; - * SIGTERM: - * - is ignored (does not interrupt) read in interactive shell; - * - terminates non-interactive shell; - * if it has non-empty trap: - * - executes trap and returns to read; - * SIGHUP: - * - terminates shell (regardless of interactivity); - * if it has non-empty trap: - * - executes trap and returns to read; - */ -static int FAST_FUNC builtin_read(char **argv) +static int FAST_FUNC builtin_source(char **argv) { - const char *r; - char *opt_n = NULL; - char *opt_p = NULL; - char *opt_t = NULL; - char *opt_u = NULL; - const char *ifs; - int read_flags; + char *arg_path, *filename; + FILE *input; + save_arg_t sv; + char *args_need_save; +#if ENABLE_HUSH_FUNCTIONS + smallint sv_flg; +#endif - /* "!": do not abort on errors. - * Option string must start with "sr" to match BUILTIN_READ_xxx - */ - read_flags = getopt32(argv, "!srn:p:t:u:", &opt_n, &opt_p, &opt_t, &opt_u); - if (read_flags == (uint32_t)-1) + argv = skip_dash_dash(argv); + filename = argv[0]; + if (!filename) { + /* bash says: "bash: .: filename argument required" */ + return 2; /* bash compat */ + } + arg_path = NULL; + if (!strchr(filename, '/')) { + arg_path = find_in_path(filename); + if (arg_path) + filename = arg_path; + } + input = remember_FILE(fopen_or_warn(filename, "r")); + free(arg_path); + if (!input) { + /* bb_perror_msg("%s", *argv); - done by fopen_or_warn */ + /* POSIX: non-interactive shell should abort here, + * not merely fail. So far no one complained :) + */ return EXIT_FAILURE; - argv += optind; - ifs = get_local_var_value("IFS"); /* can be NULL */ + } - again: - r = shell_builtin_read(set_local_var_from_halves, - argv, - ifs, - read_flags, - opt_n, - opt_p, - opt_t, - opt_u - ); +#if ENABLE_HUSH_FUNCTIONS + sv_flg = G_flag_return_in_progress; + /* "we are inside sourced file, ok to use return" */ + G_flag_return_in_progress = -1; +#endif + args_need_save = argv[1]; /* used as a boolean variable */ + if (args_need_save) + save_and_replace_G_args(&sv, argv); - if ((uintptr_t)r == 1 && errno == EINTR) { - unsigned sig = check_and_run_traps(); - if (sig && sig != SIGINT) - goto again; - } + /* "false; . ./empty_line; echo Zero:$?" should print 0 */ + G.last_exitcode = 0; + parse_and_run_file(input); + fclose_and_forget(input); - if ((uintptr_t)r > 1) { - bb_error_msg("%s", r); - r = (char*)(uintptr_t)1; - } + if (args_need_save) /* can't use argv[1] instead: "shift" can mangle it */ + restore_G_args(&sv, argv); +#if ENABLE_HUSH_FUNCTIONS + G_flag_return_in_progress = sv_flg; +#endif - return (uintptr_t)r; + return G.last_exitcode; } -#endif #if ENABLE_HUSH_TRAP static int FAST_FUNC builtin_trap(char **argv) @@ -9368,47 +9527,12 @@ static int FAST_FUNC builtin_trap(char **argv) if (argv[0][1] == '-' && argv[0][2] == '\0') { /* "--" */ argv++; } - /* else: "-something", no special meaning */ - } - new_cmd = *argv; - reset_traps: - argv++; - goto process_sig_list; -} -#endif - -#if ENABLE_HUSH_TYPE -/* http://www.opengroup.org/onlinepubs/9699919799/utilities/type.html */ -static int FAST_FUNC builtin_type(char **argv) -{ - int ret = EXIT_SUCCESS; - - while (*++argv) { - const char *type; - char *path = NULL; - - if (0) {} /* make conditional compile easier below */ - /*else if (find_alias(*argv)) - type = "an alias";*/ -#if ENABLE_HUSH_FUNCTIONS - else if (find_function(*argv)) - type = "a function"; -#endif - else if (find_builtin(*argv)) - type = "a shell builtin"; - else if ((path = find_in_path(*argv)) != NULL) - type = path; - else { - bb_error_msg("type: %s: not found", *argv); - ret = EXIT_FAILURE; - continue; - } - - printf("%s is %s\n", *argv, type); - free(path); + /* else: "-something", no special meaning */ } - - return ret; + new_cmd = *argv; + reset_traps: + argv++; + goto process_sig_list; } #endif @@ -9441,6 +9565,23 @@ static struct pipe *parse_jobspec(const char *str) return NULL; } +static int FAST_FUNC builtin_jobs(char **argv UNUSED_PARAM) +{ + struct pipe *job; + const char *status_string; + + checkjobs(NULL, 0 /*(no pid to wait for)*/); + for (job = G.job_list; job; job = job->next) { + if (job->alive_cmds == job->stopped_cmds) + status_string = "Stopped"; + else + status_string = "Running"; + + printf(JOB_STATUS_FORMAT, job->jobid, status_string, job->cmdtext); + } + return EXIT_SUCCESS; +} + /* built-in 'fg' and 'bg' handler */ static int FAST_FUNC builtin_fg_bg(char **argv) { @@ -9496,192 +9637,6 @@ static int FAST_FUNC builtin_fg_bg(char **argv) } #endif -#if ENABLE_HUSH_HELP -static int FAST_FUNC builtin_help(char **argv UNUSED_PARAM) -{ - const struct built_in_command *x; - - printf( - "Built-in commands:\n" - "------------------\n"); - for (x = bltins1; x != &bltins1[ARRAY_SIZE(bltins1)]; x++) { - if (x->b_descr) - printf("%-10s%s\n", x->b_cmd, x->b_descr); - } - return EXIT_SUCCESS; -} -#endif - -#if MAX_HISTORY && ENABLE_FEATURE_EDITING -static int FAST_FUNC builtin_history(char **argv UNUSED_PARAM) -{ - show_history(G.line_input_state); - return EXIT_SUCCESS; -} -#endif - -#if ENABLE_HUSH_JOB -static int FAST_FUNC builtin_jobs(char **argv UNUSED_PARAM) -{ - struct pipe *job; - const char *status_string; - - checkjobs(NULL, 0 /*(no pid to wait for)*/); - for (job = G.job_list; job; job = job->next) { - if (job->alive_cmds == job->stopped_cmds) - status_string = "Stopped"; - else - status_string = "Running"; - - printf(JOB_STATUS_FORMAT, job->jobid, status_string, job->cmdtext); - } - return EXIT_SUCCESS; -} -#endif - -#if ENABLE_HUSH_MEMLEAK -static int FAST_FUNC builtin_memleak(char **argv UNUSED_PARAM) -{ - void *p; - unsigned long l; - -# ifdef M_TRIM_THRESHOLD - /* Optional. Reduces probability of false positives */ - malloc_trim(0); -# endif - /* Crude attempt to find where "free memory" starts, - * sans fragmentation. */ - p = malloc(240); - l = (unsigned long)p; - free(p); - p = malloc(3400); - if (l < (unsigned long)p) l = (unsigned long)p; - free(p); - - -# if 0 /* debug */ - { - struct mallinfo mi = mallinfo(); - printf("top alloc:0x%lx malloced:%d+%d=%d\n", l, - mi.arena, mi.hblkhd, mi.arena + mi.hblkhd); - } -# endif - - if (!G.memleak_value) - G.memleak_value = l; - - l -= G.memleak_value; - if ((long)l < 0) - l = 0; - l /= 1024; - if (l > 127) - l = 127; - - /* Exitcode is "how many kilobytes we leaked since 1st call" */ - return l; -} -#endif - -static int FAST_FUNC builtin_pwd(char **argv UNUSED_PARAM) -{ - puts(get_cwd(0)); - return EXIT_SUCCESS; -} - -static int FAST_FUNC builtin_source(char **argv) -{ - char *arg_path, *filename; - FILE *input; - save_arg_t sv; - char *args_need_save; -#if ENABLE_HUSH_FUNCTIONS - smallint sv_flg; -#endif - - argv = skip_dash_dash(argv); - filename = argv[0]; - if (!filename) { - /* bash says: "bash: .: filename argument required" */ - return 2; /* bash compat */ - } - arg_path = NULL; - if (!strchr(filename, '/')) { - arg_path = find_in_path(filename); - if (arg_path) - filename = arg_path; - } - input = remember_FILE(fopen_or_warn(filename, "r")); - free(arg_path); - if (!input) { - /* bb_perror_msg("%s", *argv); - done by fopen_or_warn */ - /* POSIX: non-interactive shell should abort here, - * not merely fail. So far no one complained :) - */ - return EXIT_FAILURE; - } - -#if ENABLE_HUSH_FUNCTIONS - sv_flg = G_flag_return_in_progress; - /* "we are inside sourced file, ok to use return" */ - G_flag_return_in_progress = -1; -#endif - args_need_save = argv[1]; /* used as a boolean variable */ - if (args_need_save) - save_and_replace_G_args(&sv, argv); - - /* "false; . ./empty_line; echo Zero:$?" should print 0 */ - G.last_exitcode = 0; - parse_and_run_file(input); - fclose_and_forget(input); - - if (args_need_save) /* can't use argv[1] instead: "shift" can mangle it */ - restore_G_args(&sv, argv); -#if ENABLE_HUSH_FUNCTIONS - G_flag_return_in_progress = sv_flg; -#endif - - return G.last_exitcode; -} - -#if ENABLE_HUSH_UMASK -static int FAST_FUNC builtin_umask(char **argv) -{ - int rc; - mode_t mask; - - rc = 1; - mask = umask(0); - argv = skip_dash_dash(argv); - if (argv[0]) { - mode_t old_mask = mask; - - /* numeric umasks are taken as-is */ - /* symbolic umasks are inverted: "umask a=rx" calls umask(222) */ - if (!isdigit(argv[0][0])) - mask ^= 0777; - mask = bb_parse_mode(argv[0], mask); - if (!isdigit(argv[0][0])) - mask ^= 0777; - if ((unsigned)mask > 0777) { - mask = old_mask; - /* bash messages: - * bash: umask: 'q': invalid symbolic mode operator - * bash: umask: 999: octal number out of range - */ - bb_error_msg("%s: invalid mode '%s'", "umask", argv[0]); - rc = 0; - } - } else { - /* Mimic bash */ - printf("%04o\n", (unsigned) mask); - /* fall through and restore mask which we set to 0 */ - } - umask(mask); - - return !rc; /* rc != 0 - success */ -} -#endif - #if ENABLE_HUSH_KILL static int FAST_FUNC builtin_kill(char **argv) { @@ -9984,3 +9939,46 @@ static int FAST_FUNC builtin_return(char **argv) return rc; } #endif + +#if ENABLE_HUSH_MEMLEAK +static int FAST_FUNC builtin_memleak(char **argv UNUSED_PARAM) +{ + void *p; + unsigned long l; + +# ifdef M_TRIM_THRESHOLD + /* Optional. Reduces probability of false positives */ + malloc_trim(0); +# endif + /* Crude attempt to find where "free memory" starts, + * sans fragmentation. */ + p = malloc(240); + l = (unsigned long)p; + free(p); + p = malloc(3400); + if (l < (unsigned long)p) l = (unsigned long)p; + free(p); + + +# if 0 /* debug */ + { + struct mallinfo mi = mallinfo(); + printf("top alloc:0x%lx malloced:%d+%d=%d\n", l, + mi.arena, mi.hblkhd, mi.arena + mi.hblkhd); + } +# endif + + if (!G.memleak_value) + G.memleak_value = l; + + l -= G.memleak_value; + if ((long)l < 0) + l = 0; + l /= 1024; + if (l > 127) + l = 127; + + /* Exitcode is "how many kilobytes we leaked since 1st call" */ + return l; +} +#endif -- cgit v1.2.3-55-g6feb From 80f806cac9b418c07b149a683a4d1d989507d4d8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 10 Jan 2017 16:51:10 +0100 Subject: hush: shorten output of "help" builtin text data bss dec hex filename 891272 485 6856 898613 db635 busybox_old 891232 485 6856 898573 db60d busybox_unstripped Signed-off-by: Denys Vlasenko --- shell/hush.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index 7cce89183..ecef099ac 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -995,13 +995,13 @@ struct built_in_command { }; static const struct built_in_command bltins1[] = { - BLTIN("." , builtin_source , "Run commands in a file"), + BLTIN("." , builtin_source , "Run commands in file"), BLTIN(":" , builtin_true , NULL), #if ENABLE_HUSH_JOB - BLTIN("bg" , builtin_fg_bg , "Resume a job in the background"), + BLTIN("bg" , builtin_fg_bg , "Resume job in background"), #endif #if ENABLE_HUSH_LOOPS - BLTIN("break" , builtin_break , "Exit from a loop"), + BLTIN("break" , builtin_break , "Exit loop"), #endif BLTIN("cd" , builtin_cd , "Change directory"), #if ENABLE_HUSH_LOOPS @@ -1009,18 +1009,18 @@ static const struct built_in_command bltins1[] = { #endif BLTIN("eval" , builtin_eval , "Construct and run shell command"), BLTIN("exec" , builtin_exec , "Execute command, don't return to shell"), - BLTIN("exit" , builtin_exit , "Exit"), + BLTIN("exit" , builtin_exit , NULL), #if ENABLE_HUSH_EXPORT BLTIN("export" , builtin_export , "Set environment variables"), #endif #if ENABLE_HUSH_JOB - BLTIN("fg" , builtin_fg_bg , "Bring job into the foreground"), + BLTIN("fg" , builtin_fg_bg , "Bring job into foreground"), #endif #if ENABLE_HUSH_HELP BLTIN("help" , builtin_help , NULL), #endif #if MAX_HISTORY && ENABLE_FEATURE_EDITING - BLTIN("history" , builtin_history , "Show command history"), + BLTIN("history" , builtin_history , "Show history"), #endif #if ENABLE_HUSH_JOB BLTIN("jobs" , builtin_jobs , "List jobs"), @@ -1038,14 +1038,14 @@ static const struct built_in_command bltins1[] = { BLTIN("read" , builtin_read , "Input into variable"), #endif #if ENABLE_HUSH_FUNCTIONS - BLTIN("return" , builtin_return , "Return from a function"), + BLTIN("return" , builtin_return , "Return from function"), #endif #if ENABLE_HUSH_SET - BLTIN("set" , builtin_set , "Set/unset positional parameters"), + BLTIN("set" , builtin_set , "Set positional parameters"), #endif BLTIN("shift" , builtin_shift , "Shift positional parameters"), #if ENABLE_HUSH_BASH_COMPAT - BLTIN("source" , builtin_source , "Run commands in a file"), + BLTIN("source" , builtin_source , NULL), #endif #if ENABLE_HUSH_TRAP BLTIN("trap" , builtin_trap , "Trap signals"), @@ -1067,6 +1067,9 @@ static const struct built_in_command bltins1[] = { BLTIN("wait" , builtin_wait , "Wait for process"), #endif }; +/* These builtins won't be used if we are on NOMMU and need to re-exec + * (it's cheaper to run an external program in this case): + */ static const struct built_in_command bltins2[] = { #if ENABLE_HUSH_TEST BLTIN("[" , builtin_test , NULL), -- cgit v1.2.3-55-g6feb From 7d4aec0c3ecb0c10de60070616d9d8fb9b074497 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 11 Jan 2017 14:00:38 +0100 Subject: ash: split bash compatible extensions into separate defines. No code changes Splitting these options makes it self-documenting about what bash-compatible features we have. Signed-off-by: Kang-Che Sung Signed-off-by: Denys Vlasenko --- shell/ash.c | 175 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 101 insertions(+), 74 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 866c7de05..02545f565 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -145,15 +145,10 @@ //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o /* - * The following should be set to reflect the type of system you have: - * JOBS -> 1 if you have Berkeley job control, 0 otherwise. - * define SYSV if you are running under System V. - * define DEBUG=1 to compile in debugging ('set -o debug' to turn on) - * define DEBUG=2 to compile in and turn on debugging. - * - * When debugging is on (DEBUG is 1 and "set -o debug" was executed), - * debugging info will be written to ./trace and a quit signal - * will generate a core dump. + * DEBUG=1 to compile in debugging ('set -o debug' turns on) + * DEBUG=2 to compile in and turn on debugging. + * When debugging is on ("set -o debug" was executed, or DEBUG=2), + * debugging info is written to ./trace, quit signal generates core dump. */ #define DEBUG 0 /* Tweak debug output verbosity here */ @@ -170,9 +165,30 @@ #include #include #include /* for setting $HOSTNAME */ - #include "busybox.h" /* for applet_names */ +/* So far, all bash compat is controlled by one config option */ +/* Separate defines document which part of code implements what */ +/* function keyword */ +#define BASH_FUNCTION ENABLE_ASH_BASH_COMPAT +#define IF_BASH_FUNCTION IF_ASH_BASH_COMPAT +/* &>file */ +#define BASH_REDIR_OUTPUT ENABLE_ASH_BASH_COMPAT +#define IF_BASH_REDIR_OUTPUT IF_ASH_BASH_COMPAT +/* $'...' */ +#define BASH_DOLLAR_SQUOTE ENABLE_ASH_BASH_COMPAT +#define IF_BASH_DOLLAR_SQUOTE IF_ASH_BASH_COMPAT +#define BASH_PATTERN_SUBST ENABLE_ASH_BASH_COMPAT +#define IF_BASH_PATTERN_SUBST IF_ASH_BASH_COMPAT +#define BASH_SUBSTR ENABLE_ASH_BASH_COMPAT +#define IF_BASH_SUBSTR IF_ASH_BASH_COMPAT +/* [[ EXPR ]] */ +#define BASH_TEST2 (ENABLE_ASH_BASH_COMPAT * ENABLE_ASH_TEST) +#define BASH_SOURCE ENABLE_ASH_BASH_COMPAT +#define BASH_PIPEFAIL ENABLE_ASH_BASH_COMPAT +#define BASH_HOSTNAME_VAR ENABLE_ASH_BASH_COMPAT +#define BASH_SHLVL_VAR ENABLE_ASH_BASH_COMPAT + #if defined(__ANDROID_API__) && __ANDROID_API__ <= 24 /* Bionic at least up to version 24 has no glob() */ # undef ENABLE_ASH_INTERNAL_GLOB @@ -250,7 +266,7 @@ static const char *const optletters_optnames[] = { "b" "notify", "u" "nounset", "\0" "vi" -#if ENABLE_ASH_BASH_COMPAT +#if BASH_PIPEFAIL ,"\0" "pipefail" #endif #if DEBUG @@ -327,14 +343,14 @@ struct globals_misc { #define bflag optlist[11] #define uflag optlist[12] #define viflag optlist[13] -#if ENABLE_ASH_BASH_COMPAT +#if BASH_PIPEFAIL # define pipefail optlist[14] #else # define pipefail 0 #endif #if DEBUG -# define nolog optlist[14 + ENABLE_ASH_BASH_COMPAT] -# define debug optlist[15 + ENABLE_ASH_BASH_COMPAT] +# define nolog optlist[14 + BASH_PIPEFAIL] +# define debug optlist[15 + BASH_PIPEFAIL] #endif /* trap handler commands */ @@ -655,8 +671,10 @@ out2str(const char *p) #define VSTRIMLEFT 0x8 /* ${var#pattern} */ #define VSTRIMLEFTMAX 0x9 /* ${var##pattern} */ #define VSLENGTH 0xa /* ${#var} */ -#if ENABLE_ASH_BASH_COMPAT +#if BASH_SUBSTR #define VSSUBSTR 0xc /* ${var:position:length} */ +#endif +#if BASH_PATTERN_SUBST #define VSREPLACE 0xd /* ${var/pattern/replacement} */ #define VSREPLACEALL 0xe /* ${var//pattern/replacement} */ #endif @@ -683,7 +701,7 @@ static const char dolatstr[] ALIGN1 = { #define NDEFUN 14 #define NARG 15 #define NTO 16 -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT #define NTO2 17 #endif #define NCLOBBER 18 @@ -1093,7 +1111,7 @@ shcmd(union node *cmd, FILE *fp) case NTO: s = ">>"+1; dftfd = 1; break; case NCLOBBER: s = ">|"; dftfd = 1; break; case NAPPEND: s = ">>"; dftfd = 1; break; -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT case NTO2: #endif case NTOFD: s = ">&"; dftfd = 1; break; @@ -4455,7 +4473,8 @@ cmdputs(const char *s) static const char vstype[VSTYPE + 1][3] = { "", "}", "-", "+", "?", "=", "%", "%%", "#", "##" - IF_ASH_BASH_COMPAT(, ":", "/", "//") + IF_BASH_SUBSTR(, ":") + IF_BASH_PATTERN_SUBST(, "/", "//") }; const char *p, *str; @@ -4682,7 +4701,7 @@ cmdtxt(union node *n) case NAPPEND: p = ">>"; goto redir; -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT case NTO2: #endif case NTOFD: @@ -5209,7 +5228,7 @@ openredirect(union node *redir) goto ecreate; break; case NTO: -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT case NTO2: #endif /* Take care of noclobber mode. */ @@ -5370,7 +5389,7 @@ redirect(union node *redir, int flags) union node *tmp = redir; do { sv_pos++; -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT if (tmp->nfile.type == NTO2) sv_pos++; #endif @@ -5412,7 +5431,7 @@ redirect(union node *redir, int flags) continue; } } -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT redirect_more: #endif if (need_to_remember(sv, fd)) { @@ -5465,12 +5484,12 @@ redirect(union node *redir, int flags) } } else if (fd != newfd) { /* move newfd to fd */ dup2_or_raise(newfd, fd); -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT if (!(redir->nfile.type == NTO2 && fd == 2)) #endif close(newfd); } -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT if (redir->nfile.type == NTO2 && fd == 1) { /* We already redirected it to fd 1, now copy it to 2 */ newfd = 1; @@ -5787,15 +5806,15 @@ static char * rmescapes(char *str, int flag) { static const char qchars[] ALIGN1 = { - IF_ASH_BASH_COMPAT('/',) CTLESC, CTLQUOTEMARK, '\0' }; + IF_BASH_PATTERN_SUBST('/',) CTLESC, CTLQUOTEMARK, '\0' }; char *p, *q, *r; unsigned inquotes; unsigned protect_against_glob; unsigned globbing; - IF_ASH_BASH_COMPAT(unsigned slash = flag & RMESCAPE_SLASH;) + IF_BASH_PATTERN_SUBST(unsigned slash = flag & RMESCAPE_SLASH;) - p = strpbrk(str, qchars IF_ASH_BASH_COMPAT(+ !slash)); + p = strpbrk(str, qchars IF_BASH_PATTERN_SUBST(+ !slash)); if (!p) return str; @@ -5847,7 +5866,7 @@ rmescapes(char *str, int flag) protect_against_glob = 0; goto copy; } -#if ENABLE_ASH_BASH_COMPAT +#if BASH_PATTERN_SUBST else if (*p == '/' && slash) { /* stop handling globbing and mark location of slash */ globbing = slash = 0; @@ -6494,10 +6513,10 @@ subevalvar(char *p, char *varname, int strloc, int subtype, char *loc; char *rmesc, *rmescend; char *str; - IF_ASH_BASH_COMPAT(char *repl = NULL;) - IF_ASH_BASH_COMPAT(int pos, len, orig_len;) + IF_BASH_SUBSTR(int pos, len, orig_len;) int amount, resetloc; - IF_ASH_BASH_COMPAT(int workloc;) + IF_BASH_PATTERN_SUBST(int workloc;) + IF_BASH_PATTERN_SUBST(char *repl = NULL;) int zero; char *(*scan)(char*, char*, char*, char*, int, int); @@ -6522,7 +6541,7 @@ subevalvar(char *p, char *varname, int strloc, int subtype, varunset(p, varname, startp, varflags); /* NOTREACHED */ -#if ENABLE_ASH_BASH_COMPAT +#if BASH_SUBSTR case VSSUBSTR: //TODO: support more general format ${v:EXPR:EXPR}, // where EXPR follows $(()) rules @@ -6591,17 +6610,19 @@ subevalvar(char *p, char *varname, int strloc, int subtype, amount = loc - expdest; STADJUST(amount, expdest); return loc; -#endif +#endif /* BASH_SUBSTR */ } resetloc = expdest - (char *)stackblock(); +#if BASH_PATTERN_SUBST /* We'll comeback here if we grow the stack while handling * a VSREPLACE or VSREPLACEALL, since our pointers into the * stack will need rebasing, and we'll need to remove our work * areas each time */ - IF_ASH_BASH_COMPAT(restart:) + restart: +#endif amount = expdest - ((char *)stackblock() + resetloc); STADJUST(-amount, expdest); @@ -6626,11 +6647,11 @@ subevalvar(char *p, char *varname, int strloc, int subtype, * RMESCAPE_SLASH causes preglob to work differently on the pattern * and string. It's only used on the first call. */ - preglob(str, IF_ASH_BASH_COMPAT( + preglob(str, IF_BASH_PATTERN_SUBST( (subtype == VSREPLACE || subtype == VSREPLACEALL) && !repl ? - RMESCAPE_SLASH :) 0); + RMESCAPE_SLASH : ) 0); -#if ENABLE_ASH_BASH_COMPAT +#if BASH_PATTERN_SUBST workloc = expdest - (char *)stackblock(); if (subtype == VSREPLACE || subtype == VSREPLACEALL) { char *idx, *end; @@ -6731,7 +6752,7 @@ subevalvar(char *p, char *varname, int strloc, int subtype, STADJUST(-amount, expdest); return startp; } -#endif /* ENABLE_ASH_BASH_COMPAT */ +#endif /* BASH_PATTERN_SUBST */ subtype -= VSTRIMRIGHT; #if DEBUG @@ -6999,8 +7020,10 @@ evalvar(char *p, int flag, struct strlist *var_str_list) case VSTRIMLEFTMAX: case VSTRIMRIGHT: case VSTRIMRIGHTMAX: -#if ENABLE_ASH_BASH_COMPAT +#if BASH_SUBSTR case VSSUBSTR: +#endif +#if BASH_PATTERN_SUBST case VSREPLACE: case VSREPLACEALL: #endif @@ -7924,7 +7947,7 @@ enum { TESAC, TFI, TFOR, -#if ENABLE_ASH_BASH_COMPAT +#if BASH_FUNCTION TFUNCTION, #endif TIF, @@ -7962,7 +7985,7 @@ enum { /* 19 */ | (1u << TESAC) /* 20 */ | (1u << TFI) /* 21 */ | (0u << TFOR) -#if ENABLE_ASH_BASH_COMPAT +#if BASH_FUNCTION /* 22 */ | (0u << TFUNCTION) #endif /* 23 */ | (0u << TIF) @@ -8000,7 +8023,7 @@ static const char *const tokname_array[] = { "esac", "fi", "for", -#if ENABLE_ASH_BASH_COMPAT +#if BASH_FUNCTION "function", #endif "if", @@ -8244,7 +8267,7 @@ static const uint8_t nodesize[N_NUMBER] ALIGN1 = { [NDEFUN ] = SHELL_ALIGN(sizeof(struct narg)), [NARG ] = SHELL_ALIGN(sizeof(struct narg)), [NTO ] = SHELL_ALIGN(sizeof(struct nfile)), -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT [NTO2 ] = SHELL_ALIGN(sizeof(struct nfile)), #endif [NCLOBBER ] = SHELL_ALIGN(sizeof(struct nfile)), @@ -8326,7 +8349,7 @@ calcsize(int funcblocksize, union node *n) funcblocksize = calcsize(funcblocksize, n->narg.next); break; case NTO: -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT case NTO2: #endif case NCLOBBER: @@ -8440,7 +8463,7 @@ copynode(union node *n) new->narg.next = copynode(n->narg.next); break; case NTO: -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT case NTO2: #endif case NCLOBBER: @@ -8873,14 +8896,14 @@ expredir(union node *n) case NFROMTO: case NFROM: case NTO: -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT case NTO2: #endif case NCLOBBER: case NAPPEND: expandarg(redir->nfile.fname, &fn, EXP_TILDE | EXP_REDIR); TRACE(("expredir expanded to '%s'\n", fn.list->text)); -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT store_expfname: #endif #if 0 @@ -8902,7 +8925,7 @@ expredir(union node *n) expandarg(redir->ndup.vname, &fn, EXP_FULL | EXP_TILDE); if (fn.list == NULL) ash_msg_and_raise_error("redir error"); -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT //FIXME: we used expandarg with different args! if (!isdigit_str9(fn.list->text)) { /* >&file, not >&fd */ @@ -9298,7 +9321,7 @@ static int FAST_FUNC echocmd(int argc, char **argv) { return echo_main(argc, a #if ENABLE_ASH_PRINTF static int FAST_FUNC printfcmd(int argc, char **argv) { return printf_main(argc, argv); } #endif -#if ENABLE_ASH_TEST +#if ENABLE_ASH_TEST || BASH_TEST2 static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, argv); } #endif @@ -9308,9 +9331,9 @@ static const struct builtincmd builtintab[] = { { BUILTIN_SPEC_REG ":" , truecmd }, #if ENABLE_ASH_TEST { BUILTIN_REGULAR "[" , testcmd }, -# if ENABLE_ASH_BASH_COMPAT +#endif +#if BASH_TEST2 { BUILTIN_REGULAR "[[" , testcmd }, -# endif #endif #if ENABLE_ASH_ALIAS { BUILTIN_REG_ASSG "alias" , aliascmd }, @@ -9363,7 +9386,7 @@ static const struct builtincmd builtintab[] = { { BUILTIN_SPEC_REG "return" , returncmd }, { BUILTIN_SPEC_REG "set" , setcmd }, { BUILTIN_SPEC_REG "shift" , shiftcmd }, -#if ENABLE_ASH_BASH_COMPAT +#if BASH_SOURCE { BUILTIN_SPEC_REG "source" , dotcmd }, #endif #if ENABLE_ASH_TEST @@ -9386,7 +9409,7 @@ static const struct builtincmd builtintab[] = { #define COMMANDCMD (builtintab + \ /* . : */ 2 + \ /* [ */ 1 * ENABLE_ASH_TEST + \ - /* [[ */ 1 * ENABLE_ASH_TEST * ENABLE_ASH_BASH_COMPAT + \ + /* [[ */ 1 * BASH_TEST2 + \ /* alias */ 1 * ENABLE_ASH_ALIAS + \ /* bg */ 1 * ENABLE_ASH_JOB_CONTROL + \ /* break cd cddir */ 3) @@ -11008,10 +11031,10 @@ simplecmd(void) union node *vars, **vpp; union node **rpp, *redir; int savecheckkwd; -#if ENABLE_ASH_BASH_COMPAT +#if BASH_TEST2 smallint double_brackets_flag = 0; - smallint function_flag = 0; #endif + IF_BASH_FUNCTION(smallint function_flag = 0;) args = NULL; app = &args; @@ -11026,12 +11049,14 @@ simplecmd(void) checkkwd = savecheckkwd; t = readtoken(); switch (t) { -#if ENABLE_ASH_BASH_COMPAT +#if BASH_FUNCTION case TFUNCTION: if (peektoken() != TWORD) raise_error_unexpected_syntax(TWORD); function_flag = 1; break; +#endif +#if BASH_TEST2 case TAND: /* "&&" */ case TOR: /* "||" */ if (!double_brackets_flag) { @@ -11045,7 +11070,7 @@ simplecmd(void) n->type = NARG; /*n->narg.next = NULL; - stzalloc did it */ n->narg.text = wordtext; -#if ENABLE_ASH_BASH_COMPAT +#if BASH_TEST2 if (strcmp("[[", wordtext) == 0) double_brackets_flag = 1; else if (strcmp("]]", wordtext) == 0) @@ -11060,7 +11085,7 @@ simplecmd(void) app = &n->narg.next; savecheckkwd = 0; } -#if ENABLE_ASH_BASH_COMPAT +#if BASH_FUNCTION if (function_flag) { checkkwd = CHKNL | CHKKWD; switch (peektoken()) { @@ -11090,7 +11115,7 @@ simplecmd(void) parsefname(); /* read name of redirection file */ break; case TLP: - IF_ASH_BASH_COMPAT(do_func:) + IF_BASH_FUNCTION(do_func:) if (args && app == &args->narg.next && !vars && !redir ) { @@ -11098,7 +11123,7 @@ simplecmd(void) const char *name; /* We have a function */ - if (IF_ASH_BASH_COMPAT(!function_flag &&) readtoken() != TRP) + if (IF_BASH_FUNCTION(!function_flag &&) readtoken() != TRP) raise_error_unexpected_syntax(TRP); name = n->narg.text; if (!goodname(name) @@ -11111,7 +11136,7 @@ simplecmd(void) n->narg.next = parse_command(); return n; } - IF_ASH_BASH_COMPAT(function_flag = 0;) + IF_BASH_FUNCTION(function_flag = 0;) /* fall through */ default: tokpushback = 1; @@ -11292,7 +11317,7 @@ parse_command(void) n1 = list(0); t = TEND; break; - IF_ASH_BASH_COMPAT(case TFUNCTION:) + IF_BASH_FUNCTION(case TFUNCTION:) case TWORD: case TREDIR: tokpushback = 1; @@ -11325,7 +11350,7 @@ parse_command(void) return n1; } -#if ENABLE_ASH_BASH_COMPAT +#if BASH_DOLLAR_SQUOTE static int decode_dollar_squote(void) { @@ -11410,7 +11435,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) IF_FEATURE_SH_MATH(int parenlevel;) /* levels of parens in arithmetic */ int dqvarnest; /* levels of variables expansion within double quotes */ - IF_ASH_BASH_COMPAT(smallint bash_dollar_squote = 0;) + IF_BASH_DOLLAR_SQUOTE(smallint bash_dollar_squote = 0;) startlinno = g_parsefile->linno; bqlist = NULL; @@ -11445,7 +11470,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) USTPUTC(c, out); break; case CCTL: -#if ENABLE_ASH_BASH_COMPAT +#if BASH_DOLLAR_SQUOTE if (c == '\\' && bash_dollar_squote) { c = decode_dollar_squote(); if (c == '\0') { @@ -11506,7 +11531,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) dblquote = 1; goto quotemark; case CENDQUOTE: - IF_ASH_BASH_COMPAT(bash_dollar_squote = 0;) + IF_BASH_DOLLAR_SQUOTE(bash_dollar_squote = 0;) if (eofmark != NULL && varnest == 0) { USTPUTC(c, out); } else { @@ -11565,7 +11590,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) break; default: if (varnest == 0) { -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT if (c == '&') { //Can't call pgetc_eatbnl() here, this requires three-deep pungetc() if (pgetc() == '>') @@ -11597,7 +11622,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) len = out - (char *)stackblock(); out = stackblock(); if (eofmark == NULL) { - if ((c == '>' || c == '<' IF_ASH_BASH_COMPAT( || c == 0x100 + '>')) + if ((c == '>' || c == '<' IF_BASH_REDIR_OUTPUT( || c == 0x100 + '>')) && quotef == 0 ) { if (isdigit_str9(out)) { @@ -11685,7 +11710,7 @@ parseredir: { pungetc(); } } -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT else if (c == 0x100 + '>') { /* this flags &> redirection */ np->nfile.fd = 1; pgetc(); /* this is '>', no need to check */ @@ -11751,7 +11776,7 @@ parsesub: { if (c > 255 /* PEOA or PEOF */ || (c != '(' && c != '{' && !is_name(c) && !is_special(c)) ) { -#if ENABLE_ASH_BASH_COMPAT +#if BASH_DOLLAR_SQUOTE if (syntax != DQSYNTAX && c == '\'') bash_dollar_squote = 1; else @@ -11827,7 +11852,7 @@ parsesub: { switch (c) { case ':': c = pgetc_eatbnl(); -#if ENABLE_ASH_BASH_COMPAT +#if BASH_SUBSTR /* This check is only needed to not misinterpret * ${VAR:-WORD}, ${VAR:+WORD}, ${VAR:=WORD}, ${VAR:?WORD} * constructs. @@ -11857,7 +11882,7 @@ parsesub: { subtype++; break; } -#if ENABLE_ASH_BASH_COMPAT +#if BASH_PATTERN_SUBST case '/': /* ${v/[/]pattern/repl} */ //TODO: encode pattern and repl separately. @@ -12112,7 +12137,7 @@ xxreadtoken(void) p += xxreadtoken_doubles + 1; } else { pungetc(); -#if ENABLE_ASH_BASH_COMPAT +#if BASH_REDIR_OUTPUT if (c == '&' && cc == '>') /* &> */ break; /* return readtoken1(...) */ #endif @@ -13274,9 +13299,11 @@ init(void) setvareq((char*)defoptindvar, VTEXTFIXED); setvar0("PPID", utoa(getppid())); -#if ENABLE_ASH_BASH_COMPAT +#if BASH_SHLVL_VAR p = lookupvar("SHLVL"); setvar("SHLVL", utoa((p ? atoi(p) : 0) + 1), VEXPORT); +#endif +#if BASH_HOSTNAME_VAR if (!lookupvar("HOSTNAME")) { struct utsname uts; uname(&uts); -- cgit v1.2.3-55-g6feb From 027d3ab57d6a3a5a872543a6f30e55347d975149 Mon Sep 17 00:00:00 2001 From: Kang-Che Sung Date: Wed, 11 Jan 2017 14:18:15 +0100 Subject: hush: split bash compatible extensions into separate defines. No code changes Splitting these options makes it self-documenting about what bash-compatible features we have. Signed-off-by: Kang-Che Sung Signed-off-by: Denys Vlasenko --- shell/hush.c | 73 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 29 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index ecef099ac..fb0321a2c 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -326,6 +326,15 @@ #endif +/* So far, all bash compat is controlled by one config option */ +/* Separate defines document which part of code implements what */ +#define BASH_PATTERN_SUBST ENABLE_HUSH_BASH_COMPAT +#define BASH_SUBSTR ENABLE_HUSH_BASH_COMPAT +#define BASH_TEST2 ENABLE_HUSH_BASH_COMPAT +#define BASH_SOURCE ENABLE_HUSH_BASH_COMPAT +#define BASH_HOSTNAME_VAR ENABLE_HUSH_BASH_COMPAT + + /* Build knobs */ #define LEAK_HUNTING 0 #define BUILD_AS_NOMMU 0 @@ -411,7 +420,7 @@ #define _SPECIAL_VARS_STR "_*@$!?#" #define SPECIAL_VARS_STR ("_*@$!?#" + 1) #define NUMERIC_SPECVARS_STR ("_*@$!?#" + 3) -#if ENABLE_HUSH_BASH_COMPAT +#if BASH_PATTERN_SUBST /* Support / and // replace ops */ /* Note that // is stored as \ in "encoded" string representation */ # define VAR_ENCODED_SUBST_OPS "\\/%#:-=+?" @@ -572,7 +581,7 @@ struct command { smallint cmd_type; /* CMD_xxx */ #define CMD_NORMAL 0 #define CMD_SUBSHELL 1 -#if ENABLE_HUSH_BASH_COMPAT +#if BASH_TEST2 /* used for "[[ EXPR ]]" */ # define CMD_SINGLEWORD_NOGLOB 2 #endif @@ -947,7 +956,7 @@ static int builtin_set(char **argv) FAST_FUNC; #endif static int builtin_shift(char **argv) FAST_FUNC; static int builtin_source(char **argv) FAST_FUNC; -#if ENABLE_HUSH_TEST +#if ENABLE_HUSH_TEST || BASH_TEST2 static int builtin_test(char **argv) FAST_FUNC; #endif #if ENABLE_HUSH_TRAP @@ -1044,7 +1053,7 @@ static const struct built_in_command bltins1[] = { BLTIN("set" , builtin_set , "Set positional parameters"), #endif BLTIN("shift" , builtin_shift , "Shift positional parameters"), -#if ENABLE_HUSH_BASH_COMPAT +#if BASH_SOURCE BLTIN("source" , builtin_source , NULL), #endif #if ENABLE_HUSH_TRAP @@ -2174,7 +2183,7 @@ static void unset_vars(char **strings) free(strings); } -#if ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_BASH_COMPAT || ENABLE_HUSH_READ +#if BASH_HOSTNAME_VAR || ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_READ static void FAST_FUNC set_local_var_from_halves(const char *name, const char *val) { char *var = xasprintf("%s=%s", name, val); @@ -3633,7 +3642,7 @@ static int done_word(o_string *word, struct parse_context *ctx) (ctx->ctx_res_w == RES_SNTX)); return (ctx->ctx_res_w == RES_SNTX); } -# if ENABLE_HUSH_BASH_COMPAT +# if BASH_TEST2 if (strcmp(word->data, "[[") == 0) { command->cmd_type = CMD_SINGLEWORD_NOGLOB; } @@ -4231,7 +4240,7 @@ static int add_till_closing_bracket(o_string *dest, struct in_str *input, unsign { int ch; char dbl = end_ch & DOUBLE_CLOSE_CHAR_FLAG; -# if ENABLE_HUSH_BASH_COMPAT +# if BASH_SUBSTR || BASH_PATTERN_SUBST char end_char2 = end_ch >> 8; # endif end_ch &= (DOUBLE_CLOSE_CHAR_FLAG - 1); @@ -4242,7 +4251,11 @@ static int add_till_closing_bracket(o_string *dest, struct in_str *input, unsign syntax_error_unterm_ch(end_ch); return 0; } - if (ch == end_ch IF_HUSH_BASH_COMPAT( || ch == end_char2)) { + if (ch == end_ch +# if BASH_SUBSTR || BASH_PATTERN_SUBST + || ch == end_char2 +# endif + ) { if (!dbl) break; /* we look for closing )) of $((EXPR)) */ @@ -4395,14 +4408,14 @@ static int parse_dollar(o_string *as_string, /* Eat everything until closing '}' (or ':') */ end_ch = '}'; - if (ENABLE_HUSH_BASH_COMPAT + if (BASH_SUBSTR && ch == ':' && !strchr(MINUS_PLUS_EQUAL_QUESTION, i_peek(input)) ) { /* It's ${var:N[:M]} thing */ end_ch = '}' * 0x100 + ':'; } - if (ENABLE_HUSH_BASH_COMPAT + if (BASH_PATTERN_SUBST && ch == '/' ) { /* It's ${var/[/]pattern[/repl]} thing */ @@ -4429,7 +4442,9 @@ static int parse_dollar(o_string *as_string, o_addchr(as_string, last_ch); } - if (ENABLE_HUSH_BASH_COMPAT && (end_ch & 0xff00)) { + if ((BASH_SUBSTR || BASH_PATTERN_SUBST) + && (end_ch & 0xff00) + ) { /* close the first block: */ o_addchr(dest, SPECIAL_VAR_SYMBOL); /* while parsing N from ${var:N[:M]} @@ -4440,7 +4455,7 @@ static int parse_dollar(o_string *as_string, goto again; } /* got '}' */ - if (end_ch == '}' * 0x100 + ':') { + if (BASH_SUBSTR && end_ch == '}' * 0x100 + ':') { /* it's ${var:N} - emulate :999999999 */ o_addstr(dest, "999999999"); } /* else: it's ${var/[/]pattern} */ @@ -4515,7 +4530,7 @@ static int parse_dollar(o_string *as_string, } #if BB_MMU -# if ENABLE_HUSH_BASH_COMPAT +# if BASH_PATTERN_SUBST #define encode_string(as_string, dest, input, dquote_end, process_bkslash) \ encode_string(dest, input, dquote_end, process_bkslash) # else @@ -4527,7 +4542,7 @@ static int parse_dollar(o_string *as_string, #else /* !MMU */ -# if ENABLE_HUSH_BASH_COMPAT +# if BASH_PATTERN_SUBST /* all parameters are needed, no macro tricks */ # else #define encode_string(as_string, dest, input, dquote_end, process_bkslash) \ @@ -4540,7 +4555,7 @@ static int encode_string(o_string *as_string, int dquote_end, int process_bkslash) { -#if !ENABLE_HUSH_BASH_COMPAT +#if !BASH_PATTERN_SUBST const int process_bkslash = 1; #endif int ch; @@ -5183,7 +5198,7 @@ static struct pipe *parse_stream(char **pstring, /*** Execution routines ***/ /* Expansion can recurse, need forward decls: */ -#if !ENABLE_HUSH_BASH_COMPAT +#if !BASH_PATTERN_SUBST /* only ${var/pattern/repl} (its pattern part) needs additional mode */ #define expand_string_to_string(str, do_unbackslash) \ expand_string_to_string(str) @@ -5304,7 +5319,7 @@ static int expand_on_ifs(int *ended_with_ifs, o_string *output, int n, const cha * Returns malloced string. * As an optimization, we return NULL if expansion is not needed. */ -#if !ENABLE_HUSH_BASH_COMPAT +#if !BASH_PATTERN_SUBST /* only ${var/pattern/repl} (its pattern part) needs additional mode */ #define encode_then_expand_string(str, process_bkslash, do_unbackslash) \ encode_then_expand_string(str) @@ -5358,7 +5373,7 @@ static arith_t expand_and_evaluate_arith(const char *arg, const char **errmsg_p) } #endif -#if ENABLE_HUSH_BASH_COMPAT +#if BASH_PATTERN_SUBST /* ${var/[/]pattern[/repl]} helpers */ static char *strstr_pattern(char *val, const char *pattern, int *size) { @@ -5410,7 +5425,7 @@ static char *replace_pattern(char *val, const char *pattern, const char *repl, c debug_printf_varexp("result:'%s'\n", result); return result; } -#endif +#endif /* BASH_PATTERN_SUBST */ /* Helper: * Handles varname... construct. @@ -5458,7 +5473,7 @@ static NOINLINE const char *expand_one_var(char **to_be_freed_pp, char *arg, cha if (exp_op == ':') { exp_op = *exp_word++; //TODO: try ${var:} and ${var:bogus} in non-bash config - if (ENABLE_HUSH_BASH_COMPAT + if (BASH_SUBSTR && (!exp_op || !strchr(MINUS_PLUS_EQUAL_QUESTION, exp_op)) ) { /* oops... it's ${var:N[:M]}, not ${var:?xxx} or some such */ @@ -5540,7 +5555,7 @@ static NOINLINE const char *expand_one_var(char **to_be_freed_pp, char *arg, cha } } } -#if ENABLE_HUSH_BASH_COMPAT +#if BASH_PATTERN_SUBST else if (exp_op == '/' || exp_op == '\\') { /* It's ${var/[/]pattern[/repl]} thing. * Note that in encoded form it has TWO parts: @@ -5587,9 +5602,9 @@ static NOINLINE const char *expand_one_var(char **to_be_freed_pp, char *arg, cha free(repl); } } -#endif +#endif /* BASH_PATTERN_SUBST */ else if (exp_op == ':') { -#if ENABLE_HUSH_BASH_COMPAT && ENABLE_FEATURE_SH_MATH +#if BASH_SUBSTR && ENABLE_FEATURE_SH_MATH /* It's ${var:N[:M]} bashism. * Note that in encoded form it has TWO parts: * var:NM @@ -5625,7 +5640,7 @@ static NOINLINE const char *expand_one_var(char **to_be_freed_pp, char *arg, cha } debug_printf_varexp("val:'%s'\n", val); } else -#endif +#endif /* HUSH_SUBSTR_EXPANSION && FEATURE_SH_MATH */ { die_if_script("malformed ${%s:...}", var); val = NULL; @@ -5915,7 +5930,7 @@ static char **expand_strvec_to_strvec(char **argv) return expand_variables(argv, EXP_FLAG_GLOB | EXP_FLAG_ESC_GLOB_CHARS); } -#if ENABLE_HUSH_BASH_COMPAT +#if BASH_TEST2 static char **expand_strvec_to_strvec_singleword_noglob(char **argv) { return expand_variables(argv, EXP_FLAG_SINGLEWORD); @@ -5930,7 +5945,7 @@ static char **expand_strvec_to_strvec_singleword_noglob(char **argv) */ static char *expand_string_to_string(const char *str, int do_unbackslash) { -#if !ENABLE_HUSH_BASH_COMPAT +#if !BASH_PATTERN_SUBST const int do_unbackslash = 1; #endif char *argv[2], **list; @@ -7652,7 +7667,7 @@ static NOINLINE int run_pipe(struct pipe *pi) } /* Expand the rest into (possibly) many strings each */ -#if ENABLE_HUSH_BASH_COMPAT +#if BASH_TEST2 if (command->cmd_type == CMD_SINGLEWORD_NOGLOB) { argv_expanded = expand_strvec_to_strvec_singleword_noglob(argv + command->assignment_cnt); } else @@ -8408,7 +8423,7 @@ int hush_main(int argc, char **argv) /* Export PWD */ set_pwd_var(/*exp:*/ 1); -#if ENABLE_HUSH_BASH_COMPAT +#if BASH_HOSTNAME_VAR /* Set (but not export) HOSTNAME unless already set */ if (!get_local_var_value("HOSTNAME")) { struct utsname uts; @@ -8816,7 +8831,7 @@ static int run_applet_main(char **argv, int (*applet_main_func)(int argc, char * return applet_main_func(argc, argv - argc); } #endif -#if ENABLE_HUSH_TEST +#if ENABLE_HUSH_TEST || BASH_TEST2 static int FAST_FUNC builtin_test(char **argv) { return run_applet_main(argv, test_main); -- cgit v1.2.3-55-g6feb From 8944c67b1f61ca6a51a485772d5d1e6a8ff3d83d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 11 Jan 2017 14:22:00 +0100 Subject: hush: reinstate [[ builtin Mike deleted it: commit 39456a18a104b228de240b265bd943251219849d Author: Mike Frysinger Date: Sat Mar 28 12:21:57 2009 +0000 stop lying about [[ test support probably because it was not properly ifdefed around, and was enabled even when bash compat is off. I just tested it - it works: $ [ *.diff = z.diff ]; echo $? 0 $ [[ *.diff = z.diff ]]; echo $? 1 Of course, not all numerous bash tricks of [[ ]] are implemented... function old new delta bltins2 60 72 +12 Signed-off-by: Denys Vlasenko --- shell/hush.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index fb0321a2c..d90c1485a 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -1083,6 +1083,9 @@ static const struct built_in_command bltins2[] = { #if ENABLE_HUSH_TEST BLTIN("[" , builtin_test , NULL), #endif +#if BASH_TEST2 + BLTIN("[[" , builtin_test , NULL), +#endif #if ENABLE_HUSH_ECHO BLTIN("echo" , builtin_echo , NULL), #endif -- cgit v1.2.3-55-g6feb From 01ccdd1d3c5221789f1ac62ced12b7984d910705 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 11 Jan 2017 16:17:59 +0100 Subject: libbb: consolidate the code to set termios unbuffered mode function old new delta set_termios_to_raw - 116 +116 count_lines 72 74 +2 powertop_main 1458 1430 -28 top_main 943 914 -29 more_main 759 714 -45 fsck_minix_main 2969 2921 -48 conspy_main 1197 1135 -62 rawmode 99 36 -63 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/6 up/down: 118/-275) Total: -157 bytes Signed-off-by: Denys Vlasenko --- editors/vi.c | 15 ++++----------- include/libbb.h | 4 ++++ libbb/lineedit.c | 2 +- libbb/xfuncs.c | 37 +++++++++++++++++++++++++++++++++++++ loginutils/getty.c | 2 +- loginutils/vlock.c | 8 ++++---- miscutils/chat.c | 1 + miscutils/conspy.c | 17 +++++++---------- miscutils/microcom.c | 1 + miscutils/rx.c | 1 + procps/powertop.c | 10 +++------- procps/top.c | 10 ++-------- shell/shell_common.c | 2 +- util-linux/fsck_minix.c | 6 +----- util-linux/more.c | 10 +++------- 15 files changed, 71 insertions(+), 55 deletions(-) (limited to 'shell') diff --git a/editors/vi.c b/editors/vi.c index b56b04bdd..1e5ef44fb 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -354,7 +354,7 @@ struct globals { #if ENABLE_FEATURE_VI_USE_SIGNALS sigjmp_buf restart; // catch_sig() #endif - struct termios term_orig, term_vi; // remember what the cooked mode was + struct termios term_orig; // remember what the cooked mode was #if ENABLE_FEATURE_VI_COLON char *initial_cmds[3]; // currently 2 entries, NULL terminated #endif @@ -462,7 +462,6 @@ struct globals { #define context_end (G.context_end ) #define restart (G.restart ) #define term_orig (G.term_orig ) -#define term_vi (G.term_vi ) #define initial_cmds (G.initial_cmds ) #define readbuffer (G.readbuffer ) #define scr_out_buf (G.scr_out_buf ) @@ -2731,15 +2730,9 @@ static char *swap_context(char *p) // goto new context for '' command make this //----- Set terminal attributes -------------------------------- static void rawmode(void) { - tcgetattr(0, &term_orig); - term_vi = term_orig; - term_vi.c_lflag &= (~ICANON & ~ECHO); // leave ISIG on - allow intr's - term_vi.c_iflag &= (~IXON & ~ICRNL); - term_vi.c_oflag &= (~ONLCR); - term_vi.c_cc[VMIN] = 1; - term_vi.c_cc[VTIME] = 0; - erase_char = term_vi.c_cc[VERASE]; - tcsetattr_stdin_TCSANOW(&term_vi); + // no TERMIOS_CLEAR_ISIG: leave ISIG on - allow signals + set_termios_to_raw(STDIN_FILENO, &term_orig, TERMIOS_RAW_CRNL); + erase_char = term_orig.c_cc[VERASE]; } static void cookmode(void) diff --git a/include/libbb.h b/include/libbb.h index abdc8c2b8..87f89c76d 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1438,6 +1438,10 @@ int get_terminal_width_height(int fd, unsigned *width, unsigned *height) FAST_FU int get_terminal_width(int fd) FAST_FUNC; int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC; +#define TERMIOS_CLEAR_ISIG (1 << 0) +#define TERMIOS_RAW_CRNL (1 << 1) +#define TERMIOS_RAW_INPUT (1 << 2) +int set_termios_to_raw(int fd, struct termios *oldterm, int flags) FAST_FUNC; /* NB: "unsigned request" is crucial! "int request" will break some arches! */ int ioctl_or_perror(int fd, unsigned request, void *argp, const char *fmt,...) __attribute__ ((format (printf, 4, 5))) FAST_FUNC; diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 31e392147..2a5d4e704 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -2325,7 +2325,7 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman /* ~ECHO, ~ECHONL: turn off echoing, including newline echoing */ /* ~ISIG: turn off INTR (ctrl-C), QUIT, SUSP */ new_settings.c_lflag &= ~(ICANON | ECHO | ECHONL | ISIG); - /* reads would block only if < 1 char is available */ + /* reads will block only if < 1 char is available */ new_settings.c_cc[VMIN] = 1; /* no timeout (reads block forever) */ new_settings.c_cc[VTIME] = 0; diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 45650edba..98d3531d6 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -311,6 +311,43 @@ int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp) return tcsetattr(STDIN_FILENO, TCSANOW, tp); } +int FAST_FUNC set_termios_to_raw(int fd, struct termios *oldterm, int flags) +{ +//TODO: lineedit, microcom and less might be adapted to use this too: +// grep for "tcsetattr" + + struct termios newterm; + + tcgetattr(fd, oldterm); + newterm = *oldterm; + + /* Turn off buffered input (ICANON) + * Turn off echoing (ECHO) + * and separate echoing of newline (ECHONL, normally off anyway) + */ + newterm.c_lflag &= ~(ICANON | ECHO | ECHONL); + if (flags & TERMIOS_CLEAR_ISIG) { + /* dont recognize INT/QUIT/SUSP chars */ + newterm.c_lflag &= ~ISIG; + } + /* reads will block only if < 1 char is available */ + newterm.c_cc[VMIN] = 1; + /* no timeout (reads block forever) */ + newterm.c_cc[VTIME] = 0; + if (flags & TERMIOS_RAW_CRNL) { + /* dont convert CR to NL on input */ + newterm.c_iflag &= ~(IXON | ICRNL); + /* dont convert NL to CR on output */ + newterm.c_oflag &= ~(ONLCR); + } + if (flags & TERMIOS_RAW_INPUT) { + /* dont convert anything on input */ + newterm.c_iflag &= ~(BRKINT|INLCR|ICRNL|IXON|IXOFF|IUCLC|IXANY|IMAXBEL); + } + + return tcsetattr(fd, TCSANOW, &newterm); +} + pid_t FAST_FUNC safe_waitpid(pid_t pid, int *wstat, int options) { pid_t r; diff --git a/loginutils/getty.c b/loginutils/getty.c index 162c1697e..ba6c784a3 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -316,7 +316,7 @@ static void init_tty_attrs(int speed) /* non-raw output; add CR to each NL */ G.tty_attrs.c_oflag = OPOST | ONLCR; - /* reads would block only if < 1 char is available */ + /* reads will block only if < 1 char is available */ G.tty_attrs.c_cc[VMIN] = 1; /* no timeout (reads block forever) */ G.tty_attrs.c_cc[VTIME] = 0; diff --git a/loginutils/vlock.c b/loginutils/vlock.c index 52ae607c9..5ba6a8780 100644 --- a/loginutils/vlock.c +++ b/loginutils/vlock.c @@ -105,12 +105,12 @@ int vlock_main(int argc UNUSED_PARAM, char **argv) ioctl(STDIN_FILENO, VT_SETMODE, &vtm); #endif +//TODO: use set_termios_to_raw() tcgetattr(STDIN_FILENO, &oterm); term = oterm; - term.c_iflag &= ~BRKINT; - term.c_iflag |= IGNBRK; - term.c_lflag &= ~ISIG; - term.c_lflag &= ~(ECHO | ECHOCTL); + term.c_iflag |= IGNBRK; /* ignore serial break (why? VTs don't have breaks, right?) */ + term.c_iflag &= ~BRKINT; /* redundant? "dont translate break to SIGINT" */ + term.c_lflag &= ~(ISIG | ECHO | ECHOCTL); /* ignore ^C ^Z, echo off */ tcsetattr_stdin_TCSANOW(&term); while (1) { diff --git a/miscutils/chat.c b/miscutils/chat.c index dc85f82fb..8df194534 100644 --- a/miscutils/chat.c +++ b/miscutils/chat.c @@ -213,6 +213,7 @@ int chat_main(int argc UNUSED_PARAM, char **argv) , signal_handler); #if ENABLE_FEATURE_CHAT_TTY_HIFI +//TODO: use set_termios_to_raw() tcgetattr(STDIN_FILENO, &tio); tio0 = tio; cfmakeraw(&tio); diff --git a/miscutils/conspy.c b/miscutils/conspy.c index d9d09d482..1f0278b47 100644 --- a/miscutils/conspy.c +++ b/miscutils/conspy.c @@ -363,7 +363,6 @@ int conspy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int conspy_main(int argc UNUSED_PARAM, char **argv) { char tty_name[sizeof(DEV_TTY "NN")]; - struct termios termbuf; unsigned opts; unsigned ttynum; int poll_timeout_ms; @@ -414,16 +413,14 @@ int conspy_main(int argc UNUSED_PARAM, char **argv) bb_signals(BB_FATAL_SIGS, cleanup); - // All characters must be passed through to us unaltered G.kbd_fd = xopen(CURRENT_TTY, O_RDONLY); - tcgetattr(G.kbd_fd, &G.term_orig); - termbuf = G.term_orig; - termbuf.c_iflag &= ~(BRKINT|INLCR|ICRNL|IXON|IXOFF|IUCLC|IXANY|IMAXBEL); - //termbuf.c_oflag &= ~(OPOST); - no, we still want \n -> \r\n - termbuf.c_lflag &= ~(ISIG|ICANON|ECHO); - termbuf.c_cc[VMIN] = 1; - termbuf.c_cc[VTIME] = 0; - tcsetattr(G.kbd_fd, TCSANOW, &termbuf); + + // All characters must be passed through to us unaltered + set_termios_to_raw(G.kbd_fd, &G.term_orig, 0 + | TERMIOS_CLEAR_ISIG // no signals on ^C ^Z etc + | TERMIOS_RAW_INPUT // turn off all input conversions + ); + //Note: termios.c_oflag &= ~(OPOST); - no, we still want \n -> \r\n poll_timeout_ms = 250; while (1) { diff --git a/miscutils/microcom.c b/miscutils/microcom.c index 04605d883..5a4bbefa9 100644 --- a/miscutils/microcom.c +++ b/miscutils/microcom.c @@ -33,6 +33,7 @@ // set raw tty mode static void xget1(int fd, struct termios *t, struct termios *oldt) { +//TODO: use set_termios_to_raw() tcgetattr(fd, oldt); *t = *oldt; cfmakeraw(t); diff --git a/miscutils/rx.c b/miscutils/rx.c index 660f66a89..36fc20a72 100644 --- a/miscutils/rx.c +++ b/miscutils/rx.c @@ -263,6 +263,7 @@ int rx_main(int argc UNUSED_PARAM, char **argv) termios_err = tcgetattr(read_fd, &tty); if (termios_err == 0) { +//TODO: use set_termios_to_raw() orig_tty = tty; cfmakeraw(&tty); tcsetattr(read_fd, TCSAFLUSH, &tty); diff --git a/procps/powertop.c b/procps/powertop.c index ce85f4191..ee806161f 100644 --- a/procps/powertop.c +++ b/procps/powertop.c @@ -683,7 +683,6 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) ullong cur_duration[MAX_CSTATE_COUNT]; char cstate_lines[MAX_CSTATE_COUNT + 2][64]; #if ENABLE_FEATURE_USE_TERMIOS - struct termios new_settings; struct pollfd pfd[1]; pfd[0].fd = 0; @@ -707,14 +706,11 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) puts("Collecting data for "DEFAULT_SLEEP_STR" seconds"); #if ENABLE_FEATURE_USE_TERMIOS - tcgetattr(0, (void *)&G.init_settings); - memcpy(&new_settings, &G.init_settings, sizeof(new_settings)); - /* Turn on unbuffered input, turn off echoing */ - new_settings.c_lflag &= ~(ISIG | ICANON | ECHO | ECHONL); + /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ + set_termios_to_raw(STDIN_FILENO, &G.init_settings, TERMIOS_CLEAR_ISIG); + bb_signals(BB_FATAL_SIGS, sig_handler); /* So we don't forget to reset term settings */ atexit(reset_term); - bb_signals(BB_FATAL_SIGS, sig_handler); - tcsetattr_stdin_TCSANOW(&new_settings); #endif /* Collect initial data */ diff --git a/procps/top.c b/procps/top.c index 491acb574..91bb8a883 100644 --- a/procps/top.c +++ b/procps/top.c @@ -1089,9 +1089,6 @@ int top_main(int argc UNUSED_PARAM, char **argv) unsigned interval; char *str_interval, *str_iterations; unsigned scan_mask = TOP_MASK; -#if ENABLE_FEATURE_USE_TERMIOS - struct termios new_settings; -#endif INIT_G(); @@ -1141,11 +1138,8 @@ int top_main(int argc UNUSED_PARAM, char **argv) } #if ENABLE_FEATURE_USE_TERMIOS else { - tcgetattr(0, (void *) &initial_settings); - memcpy(&new_settings, &initial_settings, sizeof(new_settings)); - /* unbuffered input, turn off echo */ - new_settings.c_lflag &= ~(ISIG | ICANON | ECHO | ECHONL); - tcsetattr_stdin_TCSANOW(&new_settings); + /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ + set_termios_to_raw(STDIN_FILENO, &initial_settings, TERMIOS_CLEAR_ISIG); } bb_signals(BB_FATAL_SIGS, sig_catcher); diff --git a/shell/shell_common.c b/shell/shell_common.c index 98d862744..549b17ca1 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c @@ -143,7 +143,7 @@ shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val), // Setting it to more than 1 breaks poll(): // it blocks even if there's data. !?? //tty.c_cc[VMIN] = nchars < 256 ? nchars : 255; - /* reads would block only if < 1 char is available */ + /* reads will block only if < 1 char is available */ tty.c_cc[VMIN] = 1; /* no timeout (reads block forever) */ tty.c_cc[VTIME] = 0; diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index 0eaac17c0..2ab7530ea 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c @@ -1226,7 +1226,6 @@ void check2(void); int fsck_minix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int fsck_minix_main(int argc UNUSED_PARAM, char **argv) { - struct termios tmp; int retcode = 0; xfunc_error_retval = 8; @@ -1271,10 +1270,7 @@ int fsck_minix_main(int argc UNUSED_PARAM, char **argv) read_tables(); if (OPT_manual) { - tcgetattr(0, &sv_termios); - tmp = sv_termios; - tmp.c_lflag &= ~(ICANON | ECHO); - tcsetattr_stdin_TCSANOW(&tmp); + set_termios_to_raw(STDIN_FILENO, &sv_termios, 0); termios_set = 1; } diff --git a/util-linux/more.c b/util-linux/more.c index 7fa60bdba..debad81bd 100644 --- a/util-linux/more.c +++ b/util-linux/more.c @@ -43,7 +43,6 @@ struct globals { unsigned terminal_width; unsigned terminal_height; struct termios initial_settings; - struct termios new_settings; } FIX_ALIASING; #define G (*(struct globals*)bb_common_bufsiz1) #define INIT_G() do { setup_common_bufsiz(); } while (0) @@ -101,12 +100,9 @@ int more_main(int argc UNUSED_PARAM, char **argv) return bb_cat(argv); G.tty_fileno = fileno(tty); - tcgetattr(G.tty_fileno, &G.initial_settings); - G.new_settings = G.initial_settings; - G.new_settings.c_lflag &= ~(ICANON | ECHO); - G.new_settings.c_cc[VMIN] = 1; - G.new_settings.c_cc[VTIME] = 0; - tcsetattr_tty_TCSANOW(&G.new_settings); + + /* Turn on unbuffered input; turn off echoing */ + set_termios_to_raw(G.tty_fileno, &G.initial_settings, 0); bb_signals(BB_FATAL_SIGS, gotsig); do { -- cgit v1.2.3-55-g6feb From 4c179373e07fbc1d8fc8e53c7096fce9ee4b08b6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 11 Jan 2017 18:44:15 +0100 Subject: ash: 16-bit ->nprocs field is a pain for many CPUs function old new delta getoptscmd 527 540 +13 getjob 280 286 +6 makejob 278 282 +4 forkchild 602 600 -2 waitcmd 208 205 -3 showjob 382 379 -3 getstatus 83 80 -3 dowait 408 405 -3 freejob 93 89 -4 fg_bgcmd 290 286 -4 forkshell 260 255 -5 killcmd 224 218 -6 jobno 17 11 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/10 up/down: 23/-39) Total: -16 bytes Signed-off-by: Denys Vlasenko --- shell/ash.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 02545f565..bfdd94047 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -3392,12 +3392,13 @@ struct job { #if JOBS int stopstatus; /* status of a stopped job */ #endif - uint32_t - nprocs: 16, /* number of processes */ - state: 8, + unsigned nprocs; /* number of processes */ + #define JOBRUNNING 0 /* at least one proc running */ #define JOBSTOPPED 1 /* all procs are stopped */ #define JOBDONE 2 /* all procs are completed */ + unsigned + state: 8, #if JOBS sigint: 1, /* job was killed by SIGINT */ jobctl: 1, /* job running under job control */ -- cgit v1.2.3-55-g6feb From 098b713c7b5b22fc60b606be97da431eaedc6639 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 11 Jan 2017 19:59:03 +0100 Subject: ash: commented-out possible fix for 7694 bash has a feature: it restores termios after a successful wait for a foreground job which had at least one stopped or sigkilled member. The probable rationale is that SIGSTOP and SIGKILL can preclude task from properly restoring tty state. Should we do this too? A reproducer: ^Z an interactive python: $ python Python 2.7.12 (...) >>> ^Z { python leaves tty in -icanon -echo state. We do survive that... } [1]+ Stopped python { ...however, next program (python no.2) does not survive it well: } $ python Python 2.7.12 (...) >>> Traceback (most recent call last): { above, I typed "qwerty", but -echo state is still in effect } File "", line 1, in NameError: name 'qwerty' is not defined The implementation is modeled on bash code and seems to work. However, I'm not sure we should do this. For one: what if I'd fg the stopped python instead? It'll be confused by "restored" tty state. Signed-off-by: Denys Vlasenko --- shell/ash.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 4 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index bfdd94047..d8f41327b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -3579,6 +3579,72 @@ static struct job *curjob; //lots /* number of presumed living untracked jobs */ static int jobless; //4 +#if 0 +/* Bash has a feature: it restores termios after a successful wait for + * a foreground job which had at least one stopped or sigkilled member. + * The probable rationale is that SIGSTOP and SIGKILL can preclude task from + * properly restoring tty state. Should we do this too? + * A reproducer: ^Z an interactive python: + * + * # python + * Python 2.7.12 (...) + * >>> ^Z + * { python leaves tty in -icanon -echo state. We do survive that... } + * [1]+ Stopped python + * { ...however, next program (python #2) does not survive it well: } + * # python + * Python 2.7.12 (...) + * >>> Traceback (most recent call last): + * { above, I typed "qwerty", but -echo state is still in effect } + * File "", line 1, in + * NameError: name 'qwerty' is not defined + * + * The implementation below is modeled on bash code and seems to work. + * However, I'm not sure we should do this. For one: what if I'd fg + * the stopped python instead? It'll be confused by "restored" tty state. + */ +static struct termios shell_tty_info; +static void +get_tty_state(void) +{ + if (rootshell && ttyfd >= 0) + tcgetattr(ttyfd, &shell_tty_info); +} +static void +set_tty_state(void) +{ + /* if (rootshell) - caller ensures this */ + if (ttyfd >= 0) + tcsetattr(ttyfd, TCSADRAIN, &shell_tty_info); +} +static int +job_signal_status(struct job *jp) +{ + int status; + unsigned i; + struct procstat *ps = jp->ps; + for (i = 0; i < jp->nprocs; i++) { + status = ps[i].ps_status; + if (WIFSIGNALED(status) || WIFSTOPPED(status)) + return status; + } + return 0; +} +static void +restore_tty_if_stopped_or_signaled(struct job *jp) +{ +//TODO: check what happens if we come from waitforjob() in expbackq() + if (rootshell) { + int s = job_signal_status(jp); + if (s) /* WIFSIGNALED(s) || WIFSTOPPED(s) */ + set_tty_state(); + } +} +#else +# define get_tty_state() ((void)0) +# define restore_tty_if_stopped_or_signaled(jp) ((void)0) +#endif + static void set_curjob(struct job *jp, unsigned mode) { @@ -3910,8 +3976,10 @@ restartjob(struct job *jp, int mode) goto out; jp->state = JOBRUNNING; pgid = jp->ps[0].ps_pid; - if (mode == FORK_FG) + if (mode == FORK_FG) { + get_tty_state(); xtcsetpgrp(ttyfd, pgid); + } killpg(pgid, SIGCONT); ps = jp->ps; i = jp->nprocs; @@ -4445,7 +4513,7 @@ makejob(/*union node *node,*/ int nprocs) memset(jp, 0, sizeof(*jp)); #if JOBS /* jp->jobctl is a bitfield. - * "jp->jobctl |= jobctl" likely to give awful code */ + * "jp->jobctl |= doing_jobctl" likely to give awful code */ if (doing_jobctl) jp->jobctl = 1; #endif @@ -5040,6 +5108,8 @@ waitforjob(struct job *jp) #if JOBS if (jp->jobctl) { xtcsetpgrp(ttyfd, rootpid); + restore_tty_if_stopped_or_signaled(jp); + /* * This is truly gross. * If we're doing job control, then we did a TIOCSPGRP which @@ -8852,13 +8922,15 @@ static int evalsubshell(union node *n, int flags) { struct job *jp; - int backgnd = (n->type == NBACKGND); + int backgnd = (n->type == NBACKGND); /* FORK_BG(1) if yes, else FORK_FG(0) */ int status; expredir(n->nredir.redirect); if (!backgnd && (flags & EV_EXIT) && !may_have_traps) goto nofork; INT_OFF; + if (backgnd == FORK_FG) + get_tty_state(); jp = makejob(/*n,*/ 1); if (forkshell(jp, n, backgnd) == 0) { /* child */ @@ -8873,7 +8945,7 @@ evalsubshell(union node *n, int flags) } /* parent */ status = 0; - if (!backgnd) + if (backgnd == FORK_FG) status = waitforjob(jp); INT_ON; return status; @@ -8965,6 +9037,8 @@ evalpipe(union node *n, int flags) pipelen++; flags |= EV_EXIT; INT_OFF; + if (n->npipe.pipe_backgnd == 0) + get_tty_state(); jp = makejob(/*n,*/ pipelen); prevfd = -1; for (lp = n->npipe.cmdlist; lp; lp = lp->next) { @@ -9647,6 +9721,7 @@ evalcommand(union node *cmd, int flags) if (!(flags & EV_EXIT) || may_have_traps) { /* No, forking off a child is necessary */ INT_OFF; + get_tty_state(); jp = makejob(/*cmd,*/ 1); if (forkshell(jp, cmd, FORK_FG) != 0) { /* parent */ -- cgit v1.2.3-55-g6feb From 786c9dc0c1351cea34e71a91c6bf34a3c62b19d4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 26 Jan 2017 18:31:51 +0100 Subject: sh: fix FEATURE_SH_STANDALONE help text: it does not enable NOFORK Signed-off-by: Denys Vlasenko --- shell/Config.src | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'shell') diff --git a/shell/Config.src b/shell/Config.src index 3545f05dd..6a7e12aa7 100644 --- a/shell/Config.src +++ b/shell/Config.src @@ -121,23 +121,11 @@ config FEATURE_SH_STANDALONE for use as a rescue shell, in the event that you screw up your system. This is implemented by re-execing /proc/self/exe (typically) - with right parameters. Some selected applets ("NOFORK" applets) - can even be executed without creating new process. - Instead, busybox will call _main() internally. - - However, this causes problems in chroot jails without mounted /proc - and with ps/top (command name can be shown as 'exe' for applets - started this way). -# untrue? -# Note that this will *also* cause applets to take precedence -# over shell builtins of the same name. So turning this on will -# eliminate any performance gained by turning on the builtin "echo" -# and "test" commands in ash. -# untrue? -# Note that when using this option, the shell will attempt to directly -# run '/bin/busybox'. If you do not have the busybox binary sitting in -# that exact location with that exact name, this option will not work at -# all. + with right parameters. + + However, there are drawbacks: it is problematic in chroot jails without + mounted /proc, and ps/top may show command name as 'exe' for applets + started this way. config FEATURE_SH_NOFORK bool "Run 'nofork' applets directly" -- cgit v1.2.3-55-g6feb From 205d48e9480e3a60f2bf1094f67d837f1b44aea5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 29 Jan 2017 14:57:33 +0100 Subject: *: add comment about APPLET_ODDNAME format It confused me more than once Signed-off-by: Denys Vlasenko --- archival/bbunzip.c | 48 +++++++++++++++++++++++-------------------- archival/lzop.c | 3 ++- coreutils/expand.c | 1 + coreutils/who.c | 1 + findutils/grep.c | 1 + init/halt.c | 3 ++- loginutils/add-remove-shell.c | 1 + miscutils/flash_lock_unlock.c | 3 ++- miscutils/ubi_tools.c | 11 +++++----- modutils/modprobe-small.c | 5 +++-- networking/hostname.c | 1 + networking/ifupdown.c | 3 ++- printutils/lpr.c | 1 + procps/kill.c | 3 ++- procps/pgrep.c | 1 + runit/chpst.c | 3 ++- selinux/setfiles.c | 1 + shell/ash.c | 3 ++- shell/hush.c | 5 +++-- util-linux/freeramdisk.c | 1 + util-linux/mkfs_ext2.c | 3 ++- util-linux/mkfs_minix.c | 1 + util-linux/mkfs_vfat.c | 3 ++- util-linux/setarch.c | 1 + util-linux/swaponoff.c | 3 ++- 25 files changed, 69 insertions(+), 41 deletions(-) (limited to 'shell') diff --git a/archival/bbunzip.c b/archival/bbunzip.c index fb7a3678d..0e2a261f0 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -314,6 +314,7 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv) //config: depends on (GUNZIP || ZCAT) && LONG_OPTS //applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_ZCAT(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat)) #if ENABLE_FEATURE_GZIP_DECOMPRESS static @@ -425,6 +426,7 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) //config: Alias to "bunzip2 -c". //applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_BZCAT(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) #if ENABLE_FEATURE_BZIP2_DECOMPRESS int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; @@ -467,26 +469,6 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv) //usage: "[FILE]..." //usage:#define lzcat_full_usage "\n\n" //usage: "Decompress to stdout" -//usage: -//usage:#define unxz_trivial_usage -//usage: "[-cf] [FILE]..." -//usage:#define unxz_full_usage "\n\n" -//usage: "Decompress FILE (or stdin)\n" -//usage: "\n -c Write to stdout" -//usage: "\n -f Force" -//usage: -//usage:#define xz_trivial_usage -//usage: "-d [-cf] [FILE]..." -//usage:#define xz_full_usage "\n\n" -//usage: "Decompress FILE (or stdin)\n" -//usage: "\n -d Decompress" -//usage: "\n -c Write to stdout" -//usage: "\n -f Force" -//usage: -//usage:#define xzcat_trivial_usage -//usage: "[FILE]..." -//usage:#define xzcat_full_usage "\n\n" -//usage: "Decompress to stdout" //config:config UNLZMA //config: bool "unlzma" @@ -528,8 +510,9 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv) //config: a 1K bigger binary. //applet:IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_LZCAT(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat)) -//applet:IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma)) +//applet:IF_LZMA( APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma)) //kbuild:lib-$(CONFIG_UNLZMA) += bbunzip.o //kbuild:lib-$(CONFIG_LZCAT) += bbunzip.o //kbuild:lib-$(CONFIG_LZMA) += bbunzip.o @@ -553,6 +536,26 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv) #endif +//usage:#define unxz_trivial_usage +//usage: "[-cf] [FILE]..." +//usage:#define unxz_full_usage "\n\n" +//usage: "Decompress FILE (or stdin)\n" +//usage: "\n -c Write to stdout" +//usage: "\n -f Force" +//usage: +//usage:#define xz_trivial_usage +//usage: "-d [-cf] [FILE]..." +//usage:#define xz_full_usage "\n\n" +//usage: "Decompress FILE (or stdin)\n" +//usage: "\n -d Decompress" +//usage: "\n -c Write to stdout" +//usage: "\n -f Force" +//usage: +//usage:#define xzcat_trivial_usage +//usage: "[FILE]..." +//usage:#define xzcat_full_usage "\n\n" +//usage: "Decompress to stdout" + //config:config UNXZ //config: bool "unxz" //config: default y @@ -573,8 +576,9 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv) //config: IOW: you'll get xz applet, but it will always require -d option. //applet:IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_XZCAT(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat)) -//applet:IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz)) +//applet:IF_XZ( APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz)) //kbuild:lib-$(CONFIG_UNXZ) += bbunzip.o //kbuild:lib-$(CONFIG_XZCAT) += bbunzip.o //kbuild:lib-$(CONFIG_XZ) += bbunzip.o diff --git a/archival/lzop.c b/archival/lzop.c index e0e90ac6c..ca61add3c 100644 --- a/archival/lzop.c +++ b/archival/lzop.c @@ -53,7 +53,8 @@ //config: and take up 3.2K of code. //applet:IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP)) -//applet:IF_UNLZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_UNLZOP( APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop)) //applet:IF_LZOPCAT(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat)) //kbuild:lib-$(CONFIG_LZOP) += lzop.o //kbuild:lib-$(CONFIG_UNLZOP) += lzop.o diff --git a/coreutils/expand.c b/coreutils/expand.c index 63b682330..9ce86ebff 100644 --- a/coreutils/expand.c +++ b/coreutils/expand.c @@ -43,6 +43,7 @@ //config: depends on UNEXPAND && LONG_OPTS //applet:IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_UNEXPAND(APPLET_ODDNAME(unexpand, expand, BB_DIR_USR_BIN, BB_SUID_DROP, unexpand)) //kbuild:lib-$(CONFIG_EXPAND) += expand.o diff --git a/coreutils/who.c b/coreutils/who.c index ac19dc720..e6179bb00 100644 --- a/coreutils/who.c +++ b/coreutils/who.c @@ -30,6 +30,7 @@ //config: help //config: Print users currently logged on. +// APPLET_ODDNAME:name main location suid_type help //applet:IF_USERS(APPLET_ODDNAME(users, who, BB_DIR_USR_BIN, BB_SUID_DROP, users)) //applet:IF_WHO(APPLET(who, BB_DIR_USR_BIN, BB_SUID_DROP)) diff --git a/findutils/grep.c b/findutils/grep.c index 547e3d576..ec7605d85 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -46,6 +46,7 @@ //config: Print the specified number of context lines (-C). //applet:IF_GREP(APPLET(grep, BB_DIR_BIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_EGREP(APPLET_ODDNAME(egrep, grep, BB_DIR_BIN, BB_SUID_DROP, egrep)) //applet:IF_FGREP(APPLET_ODDNAME(fgrep, grep, BB_DIR_BIN, BB_SUID_DROP, fgrep)) diff --git a/init/halt.c b/init/halt.c index b7fb10869..f69b89772 100644 --- a/init/halt.c +++ b/init/halt.c @@ -46,8 +46,9 @@ //config: locating telinit executable. //applet:IF_HALT(APPLET(halt, BB_DIR_SBIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_POWEROFF(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff)) -//applet:IF_REBOOT(APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot)) +//applet:IF_REBOOT( APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot)) //kbuild:lib-$(CONFIG_HALT) += halt.o //kbuild:lib-$(CONFIG_POWEROFF) += halt.o diff --git a/loginutils/add-remove-shell.c b/loginutils/add-remove-shell.c index ce4a7bbd2..af7c31779 100644 --- a/loginutils/add-remove-shell.c +++ b/loginutils/add-remove-shell.c @@ -19,6 +19,7 @@ //config: help //config: Remove shells from /etc/shells. +// APPLET_ODDNAME:name main location suid_type help //applet:IF_ADD_SHELL( APPLET_ODDNAME(add-shell , add_remove_shell, BB_DIR_USR_SBIN, BB_SUID_DROP, add_shell )) //applet:IF_REMOVE_SHELL(APPLET_ODDNAME(remove-shell, add_remove_shell, BB_DIR_USR_SBIN, BB_SUID_DROP, remove_shell)) diff --git a/miscutils/flash_lock_unlock.c b/miscutils/flash_lock_unlock.c index 2f698641f..003496d5b 100644 --- a/miscutils/flash_lock_unlock.c +++ b/miscutils/flash_lock_unlock.c @@ -17,7 +17,8 @@ //config: The flash_unlock binary from mtd-utils as of git head 5ec0c10d0. This //config: utility unlocks part or all of the flash device. -//applet:IF_FLASH_LOCK(APPLET_ODDNAME(flash_lock, flash_lock_unlock, BB_DIR_USR_SBIN, BB_SUID_DROP, flash_lock)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_FLASH_LOCK( APPLET_ODDNAME(flash_lock, flash_lock_unlock, BB_DIR_USR_SBIN, BB_SUID_DROP, flash_lock)) //applet:IF_FLASH_UNLOCK(APPLET_ODDNAME(flash_unlock, flash_lock_unlock, BB_DIR_USR_SBIN, BB_SUID_DROP, flash_unlock)) //kbuild:lib-$(CONFIG_FLASH_LOCK) += flash_lock_unlock.o diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c index 8e55e9577..982e3e52a 100644 --- a/miscutils/ubi_tools.c +++ b/miscutils/ubi_tools.c @@ -45,11 +45,12 @@ //config: help //config: Update a UBI volume. -//applet:IF_UBIATTACH(APPLET_ODDNAME(ubiattach, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubiattach)) -//applet:IF_UBIDETACH(APPLET_ODDNAME(ubidetach, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubidetach)) -//applet:IF_UBIMKVOL(APPLET_ODDNAME(ubimkvol, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubimkvol)) -//applet:IF_UBIRMVOL(APPLET_ODDNAME(ubirmvol, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubirmvol)) -//applet:IF_UBIRSVOL(APPLET_ODDNAME(ubirsvol, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubirsvol)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_UBIATTACH( APPLET_ODDNAME(ubiattach, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubiattach)) +//applet:IF_UBIDETACH( APPLET_ODDNAME(ubidetach, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubidetach)) +//applet:IF_UBIMKVOL( APPLET_ODDNAME(ubimkvol, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubimkvol)) +//applet:IF_UBIRMVOL( APPLET_ODDNAME(ubirmvol, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubirmvol)) +//applet:IF_UBIRSVOL( APPLET_ODDNAME(ubirsvol, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubirsvol)) //applet:IF_UBIUPDATEVOL(APPLET_ODDNAME(ubiupdatevol, ubi_tools, BB_DIR_USR_SBIN, BB_SUID_DROP, ubiupdatevol)) //kbuild:lib-$(CONFIG_UBIATTACH) += ubi_tools.o diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index 21fa9dbdd..e44feeefa 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -25,10 +25,11 @@ //config: Check if the module is already loaded. //applet:IF_MODPROBE(IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP))) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_DEPMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, depmod))) //applet:IF_INSMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, insmod))) -//applet:IF_LSMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, lsmod))) -//applet:IF_RMMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, rmmod))) +//applet:IF_LSMOD(IF_MODPROBE_SMALL( APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, lsmod))) +//applet:IF_RMMOD(IF_MODPROBE_SMALL( APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, rmmod))) //kbuild:lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o diff --git a/networking/hostname.c b/networking/hostname.c index 04a051ede..9f2418422 100644 --- a/networking/hostname.c +++ b/networking/hostname.c @@ -22,6 +22,7 @@ //config: help //config: Alias to "hostname -d". +// APPLET_ODDNAME:name main location suid_type help //applet:IF_DNSDOMAINNAME(APPLET_ODDNAME(dnsdomainname, hostname, BB_DIR_BIN, BB_SUID_DROP, dnsdomainname)) //applet:IF_HOSTNAME(APPLET(hostname, BB_DIR_BIN, BB_SUID_DROP)) diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 78baa6690..a76fe1021 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c @@ -106,7 +106,8 @@ //config: Otherwise, if udhcpc applet is enabled, it is used. //config: Otherwise, ifup/ifdown will have no support for DHCP. -//applet:IF_IFUP(APPLET_ODDNAME(ifup, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifup)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_IFUP( APPLET_ODDNAME(ifup, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifup)) //applet:IF_IFDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown)) //kbuild:lib-$(CONFIG_IFUP) += ifupdown.o diff --git a/printutils/lpr.c b/printutils/lpr.c index ed6a84a93..8cc87d167 100644 --- a/printutils/lpr.c +++ b/printutils/lpr.c @@ -23,6 +23,7 @@ //config: help //config: lpq is a print spool queue examination and manipulation program. +// APPLET_ODDNAME:name main location suid_type help //applet:IF_LPQ(APPLET_ODDNAME(lpq, lpqr, BB_DIR_USR_BIN, BB_SUID_DROP, lpq)) //applet:IF_LPR(APPLET_ODDNAME(lpr, lpqr, BB_DIR_USR_BIN, BB_SUID_DROP, lpr)) diff --git a/procps/kill.c b/procps/kill.c index 0ef1716a4..7ae5beead 100644 --- a/procps/kill.c +++ b/procps/kill.c @@ -33,7 +33,8 @@ //config: the script it was called from. //applet:IF_KILL(APPLET(kill, BB_DIR_BIN, BB_SUID_DROP)) -//applet:IF_KILLALL(APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_KILLALL( APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall)) //applet:IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_SBIN, BB_SUID_DROP, killall5)) //kbuild:lib-$(CONFIG_KILL) += kill.o diff --git a/procps/pgrep.c b/procps/pgrep.c index ac82b5156..e932a32bc 100644 --- a/procps/pgrep.c +++ b/procps/pgrep.c @@ -19,6 +19,7 @@ //config: Send signals to processes by name. //applet:IF_PGREP(APPLET(pgrep, BB_DIR_USR_BIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_PKILL(APPLET_ODDNAME(pkill, pgrep, BB_DIR_USR_BIN, BB_SUID_DROP, pkill)) //kbuild:lib-$(CONFIG_PGREP) += pgrep.o diff --git a/runit/chpst.c b/runit/chpst.c index 3769af25e..846c846d3 100644 --- a/runit/chpst.c +++ b/runit/chpst.c @@ -60,7 +60,8 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //config: Sets soft resource limits as specified by options //applet:IF_CHPST(APPLET(chpst, BB_DIR_USR_BIN, BB_SUID_DROP)) -//applet:IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_ENVDIR( APPLET_ODDNAME(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir)) //applet:IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envuidgid)) //applet:IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, setuidgid)) //applet:IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, softlimit)) diff --git a/selinux/setfiles.c b/selinux/setfiles.c index 9fa5d3f30..c14a67be5 100644 --- a/selinux/setfiles.c +++ b/selinux/setfiles.c @@ -30,6 +30,7 @@ //config: the same as setfiles, but usage is a little different. //applet:IF_SETFILES(APPLET(setfiles, BB_DIR_SBIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_RESTORECON(APPLET_ODDNAME(restorecon, setfiles, BB_DIR_SBIN, BB_SUID_DROP, restorecon)) //kbuild:lib-$(CONFIG_SETFILES) += setfiles.o diff --git a/shell/ash.c b/shell/ash.c index d8f41327b..e07b81c05 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -136,7 +136,8 @@ //config:endif # ash options //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) -//applet:IF_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_SH_IS_ASH( APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) //applet:IF_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) //kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o diff --git a/shell/hush.c b/shell/hush.c index d90c1485a..4123cc19e 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -277,8 +277,9 @@ //config: msh is deprecated and will be removed, please migrate to hush. //applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP)) -//applet:IF_MSH(APPLET_ODDNAME(msh, hush, BB_DIR_BIN, BB_SUID_DROP, hush)) -//applet:IF_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, hush)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_MSH( APPLET_ODDNAME(msh, hush, BB_DIR_BIN, BB_SUID_DROP, hush)) +//applet:IF_SH_IS_HUSH( APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, hush)) //applet:IF_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, hush)) //kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c index 8bc2c443b..28148fcbe 100644 --- a/util-linux/freeramdisk.c +++ b/util-linux/freeramdisk.c @@ -33,6 +33,7 @@ //config: ramdisk. If you have no use for freeing memory from a ramdisk, leave //config: this disabled. +// APPLET_ODDNAME:name main location suid_type help //applet:IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, BB_DIR_BIN, BB_SUID_DROP, fdflush)) //applet:IF_FREERAMDISK(APPLET(freeramdisk, BB_DIR_SBIN, BB_SUID_DROP)) diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 5816a208e..4a7a878ac 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -21,7 +21,8 @@ //config: help //config: Alias to "mke2fs". -//applet:IF_MKE2FS(APPLET_ODDNAME(mke2fs, mkfs_ext2, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext2)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_MKE2FS( APPLET_ODDNAME(mke2fs, mkfs_ext2, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext2)) //applet:IF_MKFS_EXT2(APPLET_ODDNAME(mkfs.ext2, mkfs_ext2, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext2)) ////////:IF_MKFS_EXT3(APPLET_ODDNAME(mkfs.ext3, mkfs_ext2, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext2)) diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index 912246b93..0dfe34705 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c @@ -80,6 +80,7 @@ //config: this. If you enabled 'mkfs_minix' then you almost certainly want to //config: be using the version 2 filesystem support. +// APPLET_ODDNAME:name main location suid_type help //applet:IF_MKFS_MINIX(APPLET_ODDNAME(mkfs.minix, mkfs_minix, BB_DIR_SBIN, BB_SUID_DROP, mkfs_minix)) //kbuild:lib-$(CONFIG_MKFS_MINIX) += mkfs_minix.o diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c index ab70853a1..1fc943430 100644 --- a/util-linux/mkfs_vfat.c +++ b/util-linux/mkfs_vfat.c @@ -21,7 +21,8 @@ //config: help //config: Alias to "mkdosfs". -//applet:IF_MKDOSFS(APPLET_ODDNAME(mkdosfs, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_MKDOSFS( APPLET_ODDNAME(mkdosfs, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) //applet:IF_MKFS_VFAT(APPLET_ODDNAME(mkfs.vfat, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) //kbuild:lib-$(CONFIG_MKDOSFS) += mkfs_vfat.o diff --git a/util-linux/setarch.c b/util-linux/setarch.c index ec473e9cb..e4124b044 100644 --- a/util-linux/setarch.c +++ b/util-linux/setarch.c @@ -31,6 +31,7 @@ //config: Alias to "setarch linux64". //applet:IF_SETARCH(APPLET(setarch, BB_DIR_BIN, BB_SUID_DROP)) +// APPLET_ODDNAME:name main location suid_type help //applet:IF_LINUX32(APPLET_ODDNAME(linux32, setarch, BB_DIR_BIN, BB_SUID_DROP, linux32)) //applet:IF_LINUX64(APPLET_ODDNAME(linux64, setarch, BB_DIR_BIN, BB_SUID_DROP, linux64)) diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index b8f4e9447..313ea0ef9 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c @@ -41,7 +41,8 @@ //config: help //config: This option enables the 'swapoff' utility. -//applet:IF_SWAPON(APPLET_ODDNAME(swapon, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapon)) +// APPLET_ODDNAME:name main location suid_type help +//applet:IF_SWAPON( APPLET_ODDNAME(swapon, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapon)) //applet:IF_SWAPOFF(APPLET_ODDNAME(swapoff, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapoff)) //kbuild:lib-$(CONFIG_SWAPON) += swaponoff.o -- cgit v1.2.3-55-g6feb From 67f6db6b2768e9af44132b0a11fbadf15c330283 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 30 Jan 2017 16:27:37 +0100 Subject: wget: add a big explanation what TLS code implements and what does not Signed-off-by: Denys Vlasenko --- networking/wget.c | 33 +++++++++++++++++++++++++++++++++ shell/Config.src | 6 +++--- 2 files changed, 36 insertions(+), 3 deletions(-) (limited to 'shell') diff --git a/networking/wget.c b/networking/wget.c index 90eedaf7a..252f94dc6 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -58,6 +58,39 @@ //config: On NOMMU machines, ssl_helper applet should be available //config: in the $PATH for this to work. Make sure to select that applet. //config: +//config: Note: currently, TLS code only makes TLS I/O work, it +//config: does *not* check that the peer is who it claims to be, etc. +//config: IOW: it uses peer-supplied public keys to establish encryption +//config: and signing keys, then encrypts and signs outgoing data and +//config: decrypts incoming data. +//config: It does not check signature hashes on the incoming data: +//config: this means that attackers manipulating TCP packets can +//config: send altered data and we unknowingly receive garbage. +//config: (This check might be relatively easy to add). +//config: It does not check public key's certificate: +//config: this means that the peer may be an attacker impersonating +//config: the server we think we are talking to. +//config: +//config: If you think this is unacceptable, consider this. As more and more +//config: servers switch to HTTPS-only operation, without such "crippled" +//config: TLS code it is *impossible* to simply download a kernel source +//config: from kernel.org. Which can in real world translate into +//config: "my small automatic tooling to build cross-compilers from sources +//config: no longer works, I need to additionally keep a local copy +//config: of ~4 megabyte source tarball of a SSL library and ~2 megabyte +//config: source of wget, need to compile and built both before I can +//config: download anything. All this despite the fact that the build +//config: is done in a QEMU sandbox on a machine with absolutely nothing +//config: worth stealing, so I don't care if someone would go to a lot +//config: of trouble to intercept my HTTPS download to send me an altered +//config: kernel tarball". +//config: +//config: If you still think this is unacceptable, send patches. +//config: +//config: If you still think this is unacceptable, do not want to send +//config: patches, but do want to waste bandwidth expaining how wrong +//config: it is, you will be ignored. +//config: //config:config FEATURE_WGET_OPENSSL //config: bool "Try to connect to HTTPS using openssl" //config: default y diff --git a/shell/Config.src b/shell/Config.src index 6a7e12aa7..ccb1b15fe 100644 --- a/shell/Config.src +++ b/shell/Config.src @@ -123,9 +123,9 @@ config FEATURE_SH_STANDALONE This is implemented by re-execing /proc/self/exe (typically) with right parameters. - However, there are drawbacks: it is problematic in chroot jails without - mounted /proc, and ps/top may show command name as 'exe' for applets - started this way. + However, there are drawbacks: it is problematic in chroot jails + without mounted /proc, and ps/top may show command name as 'exe' + for applets started this way. config FEATURE_SH_NOFORK bool "Run 'nofork' applets directly" -- cgit v1.2.3-55-g6feb From b5b21126ca9217e1f721996cbef44c019185dd5d Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 31 Jan 2017 21:58:55 +0100 Subject: ash: improve / fix glob expansion When using musl libc glob() a very long string can cause glob() to fail, which leads to an out of memory error being raised by ash. This can happen easily if a very long quoted string contains *, even though no glob expansion should ever be performed on it (since it's quoted). Fix this by properly parsing control characters and escaping and only accept unquoted metacharacters. While we're at it, unify this check for libc and built-in glob expansion Signed-off-by: Felix Fietkau Signed-off-by: Denys Vlasenko --- shell/ash.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 17 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index e07b81c05..6be3ec600 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7160,6 +7160,57 @@ addfname(const char *name) exparg.lastp = &sp->next; } +/* Avoid glob() (and thus, stat() et al) for words like "echo" */ +static int +hasmeta(const char *p) +{ + static const char chars[] ALIGN1 = { + '*', '?', '[', '\\', CTLQUOTEMARK, CTLESC, 0 + }; + + for (;;) { + p = strpbrk(p, chars); + if (!p) + break; + switch ((unsigned char) *p) { + case CTLQUOTEMARK: + for (;;) { + p++; + if (*p == CTLQUOTEMARK) + break; + if (*p == CTLESC) + p++; + if (*p == '\0') /* huh? */ + return 0; + } + break; + case '\\': + case CTLESC: + p++; + if (*p == '\0') + return 0; + break; + case '[': + if (!strchr(p + 1, ']')) { + /* It's not a properly closed [] pattern, + * but other metas may follow. Continue checking. + * my[file* _is_ globbed by bash + * and matches filenames like "my[file1". + */ + break; + } + /* fallthrough */ + default: + /* case '*': */ + /* case '?': */ + return 1; + } + p++; + } + + return 0; +} + /* If we want to use glob() from libc... */ #if !ENABLE_ASH_INTERNAL_GLOB @@ -7186,20 +7237,9 @@ expandmeta(struct strlist *str /*, int flag*/) if (fflag) goto nometa; - /* Avoid glob() (and thus, stat() et al) for words like "echo" */ - p = str->text; - while (*p) { - if (*p == '*') - goto need_glob; - if (*p == '?') - goto need_glob; - if (*p == '[') - goto need_glob; - p++; - } - goto nometa; + if (!hasmeta(str->text)) + goto nometa; - need_glob: INT_OFF; p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP); // GLOB_NOMAGIC (GNU): if no *?[ chars in pattern, return it even if no match @@ -7436,9 +7476,6 @@ expsort(struct strlist *str) static void expandmeta(struct strlist *str /*, int flag*/) { - static const char metachars[] ALIGN1 = { - '*', '?', '[', 0 - }; /* TODO - EXP_REDIR */ while (str) { @@ -7449,7 +7486,7 @@ expandmeta(struct strlist *str /*, int flag*/) if (fflag) goto nometa; - if (!strpbrk(str->text, metachars)) + if (!hasmeta(str->text)) goto nometa; savelastp = exparg.lastp; -- cgit v1.2.3-55-g6feb From 5f7c82b32f548b5a1d6a4186630e8ef496a9d5e6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 3 Feb 2017 13:00:06 +0100 Subject: ash: add INT_OFF/ON around allocations Signed-off-by: Denys Vlasenko --- shell/ash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 6be3ec600..983f7b108 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12686,7 +12686,7 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM) fullname = find_dot_file(argv[0]); argv++; args_need_save = argv[0]; - if (args_need_save) { /* . FILE ARGS, ARGS exist */ + if (args_need_save) { /* ". FILE ARGS", and ARGS are not empty */ int argc; saveparam = shellparam; shellparam.malloced = 0; @@ -13480,7 +13480,7 @@ procargs(char **argv) #if DEBUG == 2 debug = 1; #endif - /* POSIX 1003.2: first arg after -c cmd is $0, remainder $1... */ + /* POSIX 1003.2: first arg after "-c CMD" is $0, remainder $1... */ if (xminusc) { minusc = *xargv++; if (*xargv) @@ -13661,9 +13661,11 @@ int ash_main(int argc UNUSED_PARAM, char **argv) if (!hp) { hp = lookupvar("HOME"); if (hp) { + INT_OFF; hp = concat_path_file(hp, ".ash_history"); setvar0("HISTFILE", hp); free((char*)hp); + INT_ON; hp = lookupvar("HISTFILE"); } } -- cgit v1.2.3-55-g6feb