From a667a7f02066ce1a6de568d75f1062f525b3c2f0 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 26 Sep 2024 16:27:10 +0200 Subject: wget: fix compile warnings when WGET_FTP is not selected Signed-off-by: Denys Vlasenko --- networking/wget.c | 9 ++++++--- util-linux/hwclock.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/networking/wget.c b/networking/wget.c index 512bebfc2..ec3767793 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -1178,7 +1178,9 @@ static void download_one_url(const char *url) /*G.content_len = 0; - redundant, got_clen = 0 is enough */ G.got_clen = 0; G.chunked = 0; - if (use_proxy || target.protocol[0] != 'f' /*not ftp[s]*/) { + if (!ENABLE_FEATURE_WGET_FTP + || use_proxy || target.protocol[0] != 'f' /*not ftp[s]*/ + ) { /* * HTTP session */ @@ -1447,14 +1449,15 @@ However, in real world it was observed that some web servers /* For HTTP, data is pumped over the same connection */ dfp = sfp; - } else { + } #if ENABLE_FEATURE_WGET_FTP + else { /* * FTP session */ sfp = prepare_ftp_session(&dfp, &target, lsa); -#endif } +#endif free(lsa); diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index e6f0043d0..c3fd0eb57 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -366,7 +366,7 @@ static void set_rtc_param(const char **pp_rtcname, char *rtc_param) /* handle param name */ eq = strchr(rtc_param, '='); if (!eq) - bb_error_msg_and_die("expected ="); + bb_simple_error_msg_and_die("expected ="); *eq = '\0'; param.param = resolve_rtc_param_alias(rtc_param); *eq = '='; -- cgit v1.2.3-55-g6feb From be7d1b7b1701d225379bc1665487ed0871b592a5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 26 Sep 2024 23:31:15 +0200 Subject: Bump version to 1.37.0 Signed-off-by: Denys Vlasenko --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e67553d5f..1ec8ac3fd 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 1 PATCHLEVEL = 37 SUBLEVEL = 0 -EXTRAVERSION = .git +EXTRAVERSION = NAME = Unnamed # *DOCUMENTATION* -- cgit v1.2.3-55-g6feb From a023f392655d55e6e5042fedc57b89a89bf8abd4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 26 Sep 2024 23:33:06 +0200 Subject: Start 1.38.0 development cycle Signed-off-by: Denys Vlasenko --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1ec8ac3fd..9550c391a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 1 -PATCHLEVEL = 37 +PATCHLEVEL = 38 SUBLEVEL = 0 -EXTRAVERSION = +EXTRAVERSION = .git NAME = Unnamed # *DOCUMENTATION* -- cgit v1.2.3-55-g6feb From e5b0547ac834dcd34c72df9aee1cf9c326c14b6f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 27 Sep 2024 19:35:50 +0200 Subject: lineedit: make save_history() FAST_FUNC function old new delta save_history 267 266 -1 hush_exit 98 97 -1 exitshell 140 138 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-4) Total: -4 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 10 +++++----- libbb/lineedit.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 01cdb1bdc..67e7bf7b9 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1998,11 +1998,11 @@ enum { FOR_SHELL = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION | LI_INTERRUPTIBLE, }; line_input_t *new_line_input_t(int flags) FAST_FUNC; -#if ENABLE_FEATURE_EDITING_SAVEHISTORY +# if ENABLE_FEATURE_EDITING_SAVEHISTORY void free_line_input_t(line_input_t *n) FAST_FUNC; -#else -# define free_line_input_t(n) free(n) -#endif +# else +# define free_line_input_t(n) free(n) +# endif /* * maxsize must be >= 2. * Returns: @@ -2013,7 +2013,7 @@ void free_line_input_t(line_input_t *n) FAST_FUNC; int read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize) FAST_FUNC; void show_history(const line_input_t *st) FAST_FUNC; # if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT -void save_history(line_input_t *st); +void save_history(line_input_t *st) FAST_FUNC; # endif #else #define MAX_HISTORY 0 diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 543a3f11c..314fedf5c 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -1555,7 +1555,7 @@ static void load_history(line_input_t *st_parm) } # if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT -void save_history(line_input_t *st) +void FAST_FUNC save_history(line_input_t *st) { FILE *fp; -- cgit v1.2.3-55-g6feb From 2c232f1e60fc42230c4e14bc7c548ac0e6593173 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 9 Apr 2024 09:50:59 +0100 Subject: libbb: use full_write1_str() to shrink busybox_main() There are two calls to dup2() in busybox_main(). These were introduced to coerce full_write2_str() into writing to stdout. The relevant commits were: 21278dff7 (busybox: do not print help to fd 2, print it to fd 1) and 5a7c72015 (busybox --list option. +140 bytes. Rob wanted it.) Later, in commit 729ecb87b (bbconfig: make it independent from printf functions), the function full_write1_str() was added. Using this in busybox_main() allows us to drop the dup2() calls. function old new delta run_applet_and_exit 796 760 -36 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-36) Total: -36 bytes Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index d9cc48423..ad373ae1c 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -776,10 +776,9 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) help: output_width = get_terminal_width(2); - dup2(1, 2); - full_write2_str(bb_banner); /* reuse const string */ - full_write2_str(" multi-call binary.\n"); /* reuse */ - full_write2_str( + full_write1_str(bb_banner); /* reuse const string */ + full_write1_str(" multi-call binary.\n"); /* reuse */ + full_write1_str( "BusyBox is copyrighted by many authors between 1998-2015.\n" "Licensed under GPLv2. See source distribution for detailed\n" "copyright notices.\n" @@ -817,20 +816,20 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) while (*a) { int len2 = strlen(a) + 2; if (col >= (int)output_width - len2) { - full_write2_str(",\n"); + full_write1_str(",\n"); col = 0; } if (col == 0) { col = 6; - full_write2_str("\t"); + full_write1_str("\t"); } else { - full_write2_str(", "); + full_write1_str(", "); } - full_write2_str(a); + full_write1_str(a); col += len2; a += len2 - 1; } - full_write2_str("\n"); + full_write1_str("\n"); return 0; } @@ -850,14 +849,13 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) if (is_prefixed_with(argv[1], "--list")) { unsigned i = 0; const char *a = applet_names; - dup2(1, 2); while (*a) { # if ENABLE_FEATURE_INSTALLER if (argv[1][6]) /* --list-full? */ - full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); + full_write1_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); # endif - full_write2_str(a); - full_write2_str("\n"); + full_write1_str(a); + full_write1_str("\n"); i++; while (*a++ != '\0') continue; -- cgit v1.2.3-55-g6feb From dbd14c4a42454b61a5474f6243865a6ec113e60b Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 9 Apr 2024 09:51:48 +0100 Subject: libbb: send usage messages to correct stream POSIX generally requires normal output to go to stdout and diagnostic (i.e. error) output to go to stderr. When usage messages for BusyBox applets are specifically requested by the user (e.g. 'find --help') they should go to stdout; when they're emitted due to an error they should go to stderr. function old new delta bb_show_usage 148 146 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-2) Total: -2 bytes Signed-off-by: Avi Halachmi Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index ad373ae1c..d2e5900b5 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -127,17 +127,19 @@ static const char packed_usage[] ALIGN1 = { PACKED_USAGE }; void FAST_FUNC bb_show_usage(void) { if (ENABLE_SHOW_USAGE) { + ssize_t FAST_FUNC (*full_write_fn)(const char *) = + xfunc_error_retval ? full_write2_str : full_write1_str; #ifdef SINGLE_APPLET_STR /* Imagine that this applet is "true". Dont link in printf! */ const char *usage_string = unpack_usage_messages(); if (usage_string) { if (*usage_string == '\b') { - full_write2_str("No help available\n"); + full_write_fn("No help available\n"); } else { - full_write2_str("Usage: "SINGLE_APPLET_STR" "); - full_write2_str(usage_string); - full_write2_str("\n"); + full_write_fn("Usage: "SINGLE_APPLET_STR" "); + full_write_fn(usage_string); + full_write_fn("\n"); } if (ENABLE_FEATURE_CLEAN_UP) dealloc_usage_messages((char*)usage_string); @@ -153,19 +155,19 @@ void FAST_FUNC bb_show_usage(void) while (*p++) continue; ap--; } - full_write2_str(bb_banner); - full_write2_str(" multi-call binary.\n"); /* common string */ + full_write_fn(bb_banner); + full_write_fn(" multi-call binary.\n"); /* common string */ if (*p == '\b') - full_write2_str("\nNo help available\n"); + full_write_fn("\nNo help available\n"); else { - full_write2_str("\nUsage: "); - full_write2_str(applet_name); + full_write_fn("\nUsage: "); + full_write_fn(applet_name); if (p[0]) { if (p[0] != '\n') - full_write2_str(" "); - full_write2_str(p); + full_write_fn(" "); + full_write_fn(p); } - full_write2_str("\n"); + full_write_fn("\n"); } if (ENABLE_FEATURE_CLEAN_UP) dealloc_usage_messages((char*)usage_string); @@ -268,8 +270,10 @@ void lbb_prepare(const char *applet && !(ENABLE_TRUE && strcmp(applet_name, "true") == 0) && !(ENABLE_FALSE && strcmp(applet_name, "false") == 0) && !(ENABLE_ECHO && strcmp(applet_name, "echo") == 0) - ) + ) { + xfunc_error_retval = 0; bb_show_usage(); + } } #endif } -- cgit v1.2.3-55-g6feb From 480a07bd6828285628abbbe3fe8e5e3b25ce1a92 Mon Sep 17 00:00:00 2001 From: Sam James Date: Tue, 23 Apr 2024 21:10:18 +0100 Subject: fixdep: add fstat error handling When `fstat` fails, `st` is left uninitialised. In our case, Ben Kohler noticed our release media builds were failing in Gentoo on x86 when building busybox with occasional SIGBUS. This turned out to be EOVERFLOW (from 32-bit ino_t) which wasn't being reported because nothing was checking the return value from `fstat`. Fix that to avoid UB (use of uninit var) and to give a more friendly error to the user. This actually turns out to be fixed already in the kernel from back in 2010 [0] and 2016 [1]. [0] https://github.com/torvalds/linux/commit/a3ba81131aca243bfecfa78c42edec0cd69f72d6 [1] https://github.com/torvalds/linux/commit/46fe94ad18aa7ce6b3dad8c035fb538942020f2b Reported-by: Ben Kohler Signed-off-by: Sam James Signed-off-by: Denys Vlasenko --- scripts/basic/fixdep.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 66be73aad..071c3b407 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -105,6 +105,7 @@ #include #include #include +#include #include #include #include @@ -292,7 +293,10 @@ void do_config_file(char *filename) perror(filename); exit(2); } - fstat(fd, &st); + if (fstat(fd, &st) < 0) { + fprintf(stderr, "fixdep: fstat %s %s\n", filename, strerror(errno)); + exit(2); + } if (st.st_size == 0) { close(fd); return; @@ -368,7 +372,10 @@ void print_deps(void) perror(depfile); exit(2); } - fstat(fd, &st); + if (fstat(fd, &st) < 0) { + fprintf(stderr, "fixdep: fstat %s %s\n", depfile, strerror(errno)); + exit(2); + } if (st.st_size == 0) { fprintf(stderr,"fixdep: %s is empty\n",depfile); close(fd); -- cgit v1.2.3-55-g6feb From 26895db35d4b9160ff5f2fe1f942e1ddbf58747d Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 18 Jul 2024 14:59:30 +0100 Subject: ed: fix line insertion before current line. Closes 15081 When text is inserted by insertLine() the lines following the insertion are moved down and the insertion point is made the new current line. To avoid too much scanning of the linked list of lines setCurNum() may use the position of the old current line to determine the location of the new current line. If the insertion point is before the old current line in the file the latter will have been moved down, so its line pointer needs to be adjusted. function old new delta insertLine 162 180 +18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 18/0) Total: 18 bytes Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- editors/ed.c | 2 ++ testsuite/ed.tests | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 testsuite/ed.tests diff --git a/editors/ed.c b/editors/ed.c index 8ec23d07f..a02634ec7 100644 --- a/editors/ed.c +++ b/editors/ed.c @@ -345,6 +345,8 @@ static int insertLine(int num, const char *data, int len) lp->prev->next = newLp; lp->prev = newLp; + if (num <= curNum) + curLine = curLine->prev; lastNum++; dirty = TRUE; return setCurNum(num); diff --git a/testsuite/ed.tests b/testsuite/ed.tests new file mode 100755 index 000000000..475fdc244 --- /dev/null +++ b/testsuite/ed.tests @@ -0,0 +1,21 @@ +#!/bin/sh + +. ./testing.sh + +# testing "test name" "command" "expected result" "file input" "stdin" + +testing "ed insert text before current line" \ + "ed input" "8\n1\ntext\n2\n3\n4\n13\n" "1\n2\n3\n4\n" '2i +text +. +,p +w +q +' + +testing "ed read text before current line" \ + "ed input" "8\n8\n1\n2\n1\n2\n3\n4\n3\n4\n16\n" "1\n2\n3\n4\n" '2r input +,p +w +q +' -- cgit v1.2.3-55-g6feb From 39c5c08b28f14e02611d5c79e357fb7432da1e25 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sat, 27 Jul 2024 07:51:35 +0100 Subject: lineedit: use stdout for shell history builtin Commit fd47f0567 (lineedit: print prompt and editing operations to stderr) changed various print statements to output to stderr. The change in show_history() caused the shell history builtin to send its output to stderr. Revert that part of the commit. function old new delta show_history 47 42 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5) Total: -5 bytes Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- libbb/lineedit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 314fedf5c..151208c1c 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -1463,7 +1463,7 @@ void FAST_FUNC show_history(const line_input_t *st) if (!st) return; for (i = 0; i < st->cnt_history; i++) - fprintf(stderr, "%4d %s\n", i, st->history[i]); + printf("%4d %s\n", i, st->history[i]); } # if ENABLE_FEATURE_EDITING_SAVEHISTORY -- cgit v1.2.3-55-g6feb From 24aa93d5382f2365c35d6e804b748e0a1febf2f6 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 23 Sep 2024 12:44:28 +0100 Subject: ash: reject unknown long options Commit 64f70cc755 (Add --login support) added code in options() to handle the bash-compatible '--login' option. In doing so it committed BusyBox ash to silently accepting all other long options. Restore compatibility with other ash variants by rejecting unknown long options. function old new delta options 589 624 +35 Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- shell/ash.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/ash.c b/shell/ash.c index bbd730770..8e029765d 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -11502,11 +11502,12 @@ options(int *login_sh) if (val && (c == '-')) { /* long options */ if (strcmp(p, "login") == 0) { *login_sh = 1; + break; } /* TODO: --noprofile: e.g. if I want to run emergency shell from sulogin, * I want minimal/no shell init scripts - but it insists on running it as "-ash"... */ - break; + ash_msg_and_raise_error("bad option '%s'", p - 2); } } if (c == 'o') { -- cgit v1.2.3-55-g6feb From dff444bc375e6eb4c6775dbfc753ba71b46e9797 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 28 Sep 2024 03:52:44 +0200 Subject: hush: whitespace and comment fixes Signed-off-by: Denys Vlasenko --- shell/hush.c | 70 +++++++++++++++++++++++------------------------------------- 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 707b77c9c..6b6ec7c6b 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -390,7 +390,6 @@ #define BASH_TEST2 (ENABLE_HUSH_BASH_COMPAT && ENABLE_HUSH_TEST) #define BASH_READ_D ENABLE_HUSH_BASH_COMPAT - /* Build knobs */ #define LEAK_HUNTING 0 #define BUILD_AS_NOMMU 0 @@ -411,7 +410,6 @@ */ #define ENABLE_HUSH_DOLLAR_OPS 1 - #if BUILD_AS_NOMMU # undef BB_MMU # undef USE_FOR_NOMMU @@ -640,7 +638,6 @@ typedef enum redir_type { HEREDOC_QUOTED = 2, } redir_type; - struct command { pid_t pid; /* 0 if exited */ unsigned assignment_cnt; /* how many argv[i] are assignments? */ @@ -798,7 +795,6 @@ struct function { }; #endif - /* set -/+o OPT support. (TODO: make it optional) * bash supports the following opts: * allexport off @@ -1046,7 +1042,6 @@ struct globals { G.sa.sa_flags = SA_RESTART; \ } while (0) - /* Function prototypes for builtins */ static int builtin_cd(char **argv) FAST_FUNC; #if ENABLE_HUSH_ECHO @@ -1248,8 +1243,8 @@ static const struct built_in_command bltins2[] ALIGN_PTR = { #endif }; - -/* Debug printouts. +/* + * Debug printouts. */ #if HUSH_DEBUG >= 2 /* prevent disasters with G.debug_indent < 0 */ @@ -1342,8 +1337,8 @@ static void debug_print_strings(const char *prefix, char **vv) # define debug_print_strings(prefix, vv) ((void)0) #endif - -/* Leak hunting. Use hush_leaktool.sh for post-processing. +/* + * Leak hunting. Use hush_leaktool.sh for post-processing. */ #if LEAK_HUNTING static void *xxmalloc(int lineno, size_t size) @@ -1375,8 +1370,8 @@ static void xxfree(void *ptr) # define free(p) xxfree(p) #endif - -/* Syntax and runtime errors. They always abort scripts. +/* + * Syntax and runtime errors. They always abort scripts. * In interactive use they usually discard unparsed and/or unexecuted commands * and return to the prompt. * HUSH_DEBUG >= 2 prints line number in this file where it was detected. @@ -1469,8 +1464,8 @@ static void syntax_error_unexpected_ch(unsigned lineno UNUSED_PARAM, int ch) # define syntax_error_unexpected_ch(ch) syntax_error_unexpected_ch(__LINE__, ch) #endif - -/* Utility functions +/* + * Utility functions */ /* Replace each \x with x in place, return ptr past NUL. */ static char *unbackslash(char *src) @@ -1616,8 +1611,9 @@ static int xdup_CLOEXEC_and_close(int fd, int avoid_fd) return newfd; } - -/* Manipulating HFILEs */ +/* + * Manipulating HFILEs + */ static HFILE *hfopen(const char *name) { HFILE *fp; @@ -1763,8 +1759,8 @@ static int fd_in_HFILEs(int fd) return 0; } - -/* Helpers for setting new $n and restoring them back +/* + * Helpers for setting new $n and restoring them back */ typedef struct save_arg_t { char *sv_argv0; @@ -1804,8 +1800,8 @@ static void restore_G_args(save_arg_t *sv, char **argv) IF_HUSH_SET(G.global_args_malloced = sv->sv_g_malloced;) } - -/* Basic theory of signal handling in shell +/* + * Basic theory of signal handling in shell * ======================================== * This does not describe what hush does, rather, it is current understanding * what it _should_ do. If it doesn't, it's a bug. @@ -2246,7 +2242,9 @@ static int check_and_run_traps(void) return last_sig; } - +/* + * Shell and environment variable support + */ static const char *get_cwd(int force) { if (force || G.cwd == NULL) { @@ -2261,10 +2259,6 @@ static const char *get_cwd(int force) return G.cwd; } - -/* - * Shell and environment variable support - */ static struct variable **get_ptr_to_local_var(const char *name) { struct variable **pp; @@ -2538,7 +2532,6 @@ static int unset_local_var(const char *name) } #endif - /* * Helpers for "var1=val1 var2=val2 cmd" feature */ @@ -2612,7 +2605,6 @@ static void set_vars_and_save_old(char **strings) free(strings); } - /* * Unicode helper */ @@ -2971,7 +2963,6 @@ static void setup_string_in_str(struct in_str *i, const char *s) i->p = s; } - /* * o_string support */ @@ -3703,9 +3694,9 @@ static void free_pipe_list(struct pipe *pi) } } - -/*** Parsing routines ***/ - +/* + * Parsing routines + */ #ifndef debug_print_tree static void debug_print_tree(struct pipe *pi, int lvl) { @@ -4339,7 +4330,6 @@ static int done_word(struct parse_context *ctx) return 0; } - /* Peek ahead in the input to find out if we have a "&n" construct, * as in "2>&1", that represents duplicating a file descriptor. * Return: @@ -4635,7 +4625,6 @@ static int fetch_heredocs(o_string *as_string, struct pipe *pi, int heredoc_cnt, return heredoc_cnt; } - static int run_list(struct pipe *pi); #if BB_MMU #define parse_stream(pstring, heredoc_cnt_ptr, input, end_trigger) \ @@ -6082,9 +6071,9 @@ static struct pipe *parse_stream(char **pstring, } } - -/*** Execution routines ***/ - +/* + * Execution routines + */ /* Expansion can recurse, need forward decls: */ #if !BASH_PATTERN_SUBST && !ENABLE_HUSH_CASE #define expand_string_to_string(str, EXP_flags, do_unbackslash) \ @@ -7347,7 +7336,6 @@ static char **expand_assignments(char **argv, int count) return p; } - static void switch_off_special_sigs(unsigned mask) { unsigned sig = 0; @@ -7565,7 +7553,6 @@ static void re_execute_shell(char ***to_free, const char *s, } #endif /* !BB_MMU */ - static int run_and_free_list(struct pipe *pi); /* Executing from string: eval, sh -c '...' @@ -7796,7 +7783,6 @@ static int process_command_subs(o_string *dest, const char *s) } #endif /* ENABLE_HUSH_TICK */ - static void setup_heredoc(struct redir_struct *redir) { struct fd_pair pair; @@ -8524,7 +8510,6 @@ static int run_function(const struct function *funcp, char **argv) } #endif /* ENABLE_HUSH_FUNCTIONS */ - #if BB_MMU #define exec_builtin(to_free, x, argv) \ exec_builtin(x, argv) @@ -8558,7 +8543,6 @@ static void exec_builtin(char ***to_free, #endif } - static void execvp_or_die(char **argv) NORETURN; static void execvp_or_die(char **argv) { @@ -10184,7 +10168,9 @@ static int run_and_free_list(struct pipe *pi) return rcode; } - +/* + * Initialization and main + */ static void install_sighandlers(unsigned mask) { sighandler_t old_handler; @@ -10861,7 +10847,6 @@ int hush_main(int argc, char **argv) hush_exit(G.last_exitcode); } - /* * Built-ins */ @@ -12340,7 +12325,6 @@ static int FAST_FUNC builtin_memleak(char **argv UNUSED_PARAM) if (l < (unsigned long)p) l = (unsigned long)p; free(p); - # if 0 /* debug */ { struct mallinfo mi = mallinfo(); -- cgit v1.2.3-55-g6feb