1303 files changed, 32187 insertions, 57138 deletions
diff --git a/util-linux/getopt.c b/util-linux/getopt.c index 58df1c8..f6ecc3d 100644 --- a/util-linux/getopt.c +++ b/util-linux/getopt.c @@ -28,8 +28,28 @@ * Removed --version/-V and --help/-h * Removed parse_error(), using bb_error_msg() from Busybox instead * Replaced our_malloc with xmalloc and our_realloc with xrealloc - * */ +//config:config GETOPT +//config: bool "getopt" +//config: default y +//config: help +//config: The getopt utility is used to break up (parse) options in command +//config: lines to make it easy to write complex shell scripts that also check +//config: for legal (and illegal) options. If you want to write horribly +//config: complex shell scripts, or use some horribly complex shell script +//config: written by others, this utility may be for you. Most people will +//config: wisely leave this disabled. +//config: +//config:config FEATURE_GETOPT_LONG +//config: bool "Support option -l" +//config: default y if LONG_OPTS +//config: depends on GETOPT +//config: help +//config: Enable support for long options (option -l). + +//applet:IF_GETOPT(APPLET(getopt, BB_DIR_BIN, BB_SUID_DROP)) + +//kbuild:lib-$(CONFIG_GETOPT) += getopt.o //usage:#define getopt_trivial_usage //usage: "[OPTIONS] [--] OPTSTRING PARAMS" @@ -327,9 +347,9 @@ static struct option *add_long_options(struct option *long_options, char *option static void set_shell(const char *new_shell) { - if (!strcmp(new_shell, "bash") || !strcmp(new_shell, "sh")) + if (strcmp(new_shell, "bash") == 0 || strcmp(new_shell, "sh") == 0) return; - if (!strcmp(new_shell, "tcsh") || !strcmp(new_shell, "csh")) + if (strcmp(new_shell, "tcsh") == 0 || strcmp(new_shell, "csh") == 0) option_mask32 |= SHELL_IS_TCSH; else bb_error_msg("unknown shell '%s', assuming bash", new_shell); @@ -378,7 +398,7 @@ int getopt_main(int argc, char **argv) if (compatible) { /* For some reason, the original getopt gave no error * when there were no arguments. */ - printf(" --\n"); + puts(" --"); return 0; } bb_error_msg_and_die("missing optstring argument"); @@ -397,8 +417,7 @@ int getopt_main(int argc, char **argv) opt = getopt32(argv, "+o:n:qQs:Tu", &optstr, &name, &s_arg); #else applet_long_options = getopt_longopts; - opt_complementary = "l::"; - opt = getopt32(argv, "+o:n:qQs:Tual:", + opt = getopt32(argv, "+o:n:qQs:Tual:*", &optstr, &name, &s_arg, &l_arg); /* Effectuate the read options for the applet itself */ while (l_arg) { |