diff options
-rw-r--r-- | coreutils/cut.c | 17 | ||||
-rw-r--r-- | libbb/getopt32.c | 4 |
2 files changed, 10 insertions, 11 deletions
diff --git a/coreutils/cut.c b/coreutils/cut.c index 2d0a6237c..1e9867858 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c | |||
@@ -27,7 +27,8 @@ | |||
27 | //kbuild:lib-$(CONFIG_CUT) += cut.o | 27 | //kbuild:lib-$(CONFIG_CUT) += cut.o |
28 | 28 | ||
29 | //usage:#define cut_trivial_usage | 29 | //usage:#define cut_trivial_usage |
30 | //usage: "[OPTIONS] [FILE]..." | 30 | //usage: "{-b|c LIST | -f"IF_FEATURE_CUT_REGEX("|F")" LIST [-d SEP] [-s]} [-D] [-O SEP] [FILE]..." |
31 | // --output-delimiter SEP is too long to fit into 80 char-wide help ----------------^^^^^^^^ | ||
31 | //usage:#define cut_full_usage "\n\n" | 32 | //usage:#define cut_full_usage "\n\n" |
32 | //usage: "Print selected fields from FILEs to stdout\n" | 33 | //usage: "Print selected fields from FILEs to stdout\n" |
33 | //usage: "\n -b LIST Output only bytes from LIST" | 34 | //usage: "\n -b LIST Output only bytes from LIST" |
@@ -44,11 +45,7 @@ | |||
44 | //usage: "\n -s Drop lines with no delimiter (else print them in full)" | 45 | //usage: "\n -s Drop lines with no delimiter (else print them in full)" |
45 | //usage: "\n -D Don't sort/collate sections or match -f"IF_FEATURE_CUT_REGEX("F")" lines without delimeter" | 46 | //usage: "\n -D Don't sort/collate sections or match -f"IF_FEATURE_CUT_REGEX("F")" lines without delimeter" |
46 | //usage: IF_LONG_OPTS( | 47 | //usage: IF_LONG_OPTS( |
47 | //usage: IF_FEATURE_CUT_REGEX( | 48 | //usage: "\n --output-delimiter SEP Output field delimeter" |
48 | //usage: "\n --output-delimiter SEP Output field delimeter (default = -d for -f, one space for -F)" | ||
49 | //usage: ) IF_NOT_FEATURE_CUT_REGEX( | ||
50 | //usage: "\n --output-delimiter SEP Output field delimeter (default = -d)" | ||
51 | //usage: ) | ||
52 | //usage: ) IF_NOT_LONG_OPTS( | 49 | //usage: ) IF_NOT_LONG_OPTS( |
53 | //usage: IF_FEATURE_CUT_REGEX( | 50 | //usage: IF_FEATURE_CUT_REGEX( |
54 | //usage: "\n -O SEP Output field delimeter (default = -d for -f, one space for -F)" | 51 | //usage: "\n -O SEP Output field delimeter (default = -d for -f, one space for -F)" |
@@ -302,7 +299,8 @@ int cut_main(int argc UNUSED_PARAM, char **argv) | |||
302 | #else | 299 | #else |
303 | opt = getopt32long(argv, "^" | 300 | opt = getopt32long(argv, "^" |
304 | OPT_STR // = "b:c:f:d:O:sD"IF_FEATURE_CUT_REGEX("F:")"n" | 301 | OPT_STR // = "b:c:f:d:O:sD"IF_FEATURE_CUT_REGEX("F:")"n" |
305 | "\0" "b--"ARG":c--"ARG":f--"ARG IF_FEATURE_CUT_REGEX("F--"ARG), | 302 | "\0" "b:c:f:"IF_FEATURE_CUT_REGEX("F:") /* one of -bcfF is required */ |
303 | "b--"ARG":c--"ARG":f--"ARG IF_FEATURE_CUT_REGEX(":F--"ARG), /* they are mutually exclusive */ | ||
306 | cut_longopts, | 304 | cut_longopts, |
307 | &sopt, &sopt, &sopt, &delim, &odelim IF_FEATURE_CUT_REGEX(, &sopt) | 305 | &sopt, &sopt, &sopt, &delim, &odelim IF_FEATURE_CUT_REGEX(, &sopt) |
308 | ); | 306 | ); |
@@ -314,8 +312,9 @@ int cut_main(int argc UNUSED_PARAM, char **argv) | |||
314 | 312 | ||
315 | // argc -= optind; | 313 | // argc -= optind; |
316 | argv += optind; | 314 | argv += optind; |
317 | if (!(opt & (OPT_BYTE | OPT_CHAR | OPT_FIELDS | OPT_REGEX))) | 315 | //if (!(opt & (OPT_BYTE | OPT_CHAR | OPT_FIELDS | OPT_REGEX))) |
318 | bb_simple_error_msg_and_die("expected a list of bytes, characters, or fields"); | 316 | // bb_simple_error_msg_and_die("expected a list of bytes, characters, or fields"); |
317 | // ^^^ handled by getopt32 | ||
319 | 318 | ||
320 | /* non-field (char or byte) cutting has some special handling */ | 319 | /* non-field (char or byte) cutting has some special handling */ |
321 | if (!(opt & (OPT_FIELDS|OPT_REGEX))) { | 320 | if (!(opt & (OPT_FIELDS|OPT_REGEX))) { |
diff --git a/libbb/getopt32.c b/libbb/getopt32.c index a8dd85159..b5efa19ac 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c | |||
@@ -93,7 +93,7 @@ getopt32(char **argv, const char *applet_opts, ...) | |||
93 | 93 | ||
94 | "!" If the first character in the applet_opts string is a '!', | 94 | "!" If the first character in the applet_opts string is a '!', |
95 | report bad options, missing required options, | 95 | report bad options, missing required options, |
96 | inconsistent options with all-ones return value (instead of abort. | 96 | inconsistent options with all-ones return value instead of aborting. |
97 | 97 | ||
98 | "+" If the first character in the applet_opts string is a plus, | 98 | "+" If the first character in the applet_opts string is a plus, |
99 | then option processing will stop as soon as a non-option is | 99 | then option processing will stop as soon as a non-option is |
@@ -265,7 +265,7 @@ Special characters: | |||
265 | for "long options only" cases, such as tar --exclude=PATTERN, | 265 | for "long options only" cases, such as tar --exclude=PATTERN, |
266 | wget --header=HDR cases. | 266 | wget --header=HDR cases. |
267 | 267 | ||
268 | "a?b" A "?" between an option and a group of options means that | 268 | "a?bc" A "?" between an option and a group of options means that |
269 | at least one of them is required to occur if the first option | 269 | at least one of them is required to occur if the first option |
270 | occurs in preceding command line arguments. | 270 | occurs in preceding command line arguments. |
271 | 271 | ||