*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
+//config:config CUT
+//config: bool "cut (5.3 kb)"
+//config: default y
+//config: help
+//config: cut is used to print selected parts of lines from
+//config: each file to stdout.
+
+//applet:IF_CUT(APPLET_NOEXEC(cut, cut, BB_DIR_USR_BIN, BB_SUID_DROP, cut))
+
+//kbuild:lib-$(CONFIG_CUT) += cut.o
//usage:#define cut_trivial_usage
//usage: "[OPTIONS] [FILE]..."
//usage:#define cut_full_usage "\n\n"
//usage: "Print selected fields from each input FILE to stdout\n"
-//usage: "\nOptions:"
//usage: "\n -b LIST Output only bytes from LIST"
//usage: "\n -c LIST Output only characters from LIST"
//usage: "\n -d CHAR Use CHAR instead of tab as the field delimiter"
/* option vars */
-static const char optstring[] ALIGN1 = "b:c:f:d:sn";
+#define OPT_STR "b:c:f:d:sn"
#define CUT_OPT_BYTE_FLGS (1 << 0)
#define CUT_OPT_CHAR_FLGS (1 << 1)
#define CUT_OPT_FIELDS_FLGS (1 << 2)
char *sopt, *ltok;
unsigned opt;
- opt_complementary = "b--bcf:c--bcf:f--bcf";
- opt = getopt32(argv, optstring, &sopt, &sopt, &sopt, <ok);
+ opt = getopt32(argv, "^"
+ OPT_STR
+ "\0" "b--bcf:c--bcf:f--bcf",
+ &sopt, &sopt, &sopt, <ok
+ );
// argc -= optind;
argv += optind;
if (!(opt & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
if (opt & CUT_OPT_SUPPRESS_FLGS) {
bb_error_msg_and_die
("suppressing non-delimited lines makes sense%s",
- _op_on_field);
+ _op_on_field);
}
if (delim != '\t') {
bb_error_msg_and_die