X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=util-linux%2Fgetopt.c;h=c45edf8ca0b39b67e5c280d5e06472566d008300;hb=c2a06db69de7562024524a89a7b0f0f7e61c5999;hp=7c498538f013724386cfb1cce1f7dd8368ab93a9;hpb=0ef64bdb40c54681e8dd5ab8df42ac88e4ab1d4a;p=oweals%2Fbusybox.git diff --git a/util-linux/getopt.c b/util-linux/getopt.c index 7c498538f..c45edf8ca 100644 --- a/util-linux/getopt.c +++ b/util-linux/getopt.c @@ -25,13 +25,62 @@ * Added NLS support (partly written by Arkadiusz Mickiewicz * ) * Ported to Busybox - Alfred M. Szmidt - * Removed --version/-V and --help/-h in + * 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 * */ -#include +//usage:#define getopt_trivial_usage +//usage: "[OPTIONS]" +//usage:#define getopt_full_usage "\n\n" +//usage: IF_LONG_OPTS( +//usage: " -a,--alternative Allow long options starting with single -" +//usage: "\n -l,--longoptions=longopts Long options to be recognized" +//usage: "\n -n,--name=progname The name under which errors are reported" +//usage: "\n -o,--options=optstring Short options to be recognized" +//usage: "\n -q,--quiet Disable error reporting by getopt(3)" +//usage: "\n -Q,--quiet-output No normal output" +//usage: "\n -s,--shell=shell Set shell quoting conventions" +//usage: "\n -T,--test Test for getopt(1) version" +//usage: "\n -u,--unquoted Don't quote the output" +//usage: ) +//usage: IF_NOT_LONG_OPTS( +//usage: " -a Allow long options starting with single -" +//usage: "\n -l longopts Long options to be recognized" +//usage: "\n -n progname The name under which errors are reported" +//usage: "\n -o optstring Short options to be recognized" +//usage: "\n -q Disable error reporting by getopt(3)" +//usage: "\n -Q No normal output" +//usage: "\n -s shell Set shell quoting conventions" +//usage: "\n -T Test for getopt(1) version" +//usage: "\n -u Don't quote the output" +//usage: ) +//usage: +//usage:#define getopt_example_usage +//usage: "$ cat getopt.test\n" +//usage: "#!/bin/sh\n" +//usage: "GETOPT=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \\\n" +//usage: " -n 'example.busybox' -- \"$@\"`\n" +//usage: "if [ $? != 0 ]; then exit 1; fi\n" +//usage: "eval set -- \"$GETOPT\"\n" +//usage: "while true; do\n" +//usage: " case $1 in\n" +//usage: " -a|--a-long) echo \"Option a\"; shift;;\n" +//usage: " -b|--b-long) echo \"Option b, argument '$2'\"; shift 2;;\n" +//usage: " -c|--c-long)\n" +//usage: " case \"$2\" in\n" +//usage: " \"\") echo \"Option c, no argument\"; shift 2;;\n" +//usage: " *) echo \"Option c, argument '$2'\"; shift 2;;\n" +//usage: " esac;;\n" +//usage: " --) shift; break;;\n" +//usage: " *) echo \"Internal error!\"; exit 1;;\n" +//usage: " esac\n" +//usage: "done\n" + +#if ENABLE_FEATURE_GETOPT_LONG +# include +#endif #include "libbb.h" /* NON_OPT is the code that is returned when a non-option is found in '+'