cut: shorten error messages on bad syntax

We don't need to mimic GNU cut error messages.

$ cut -d@ -b3
cut: -d DELIM makes sense only with -f or -F
$ cut -s -b3
cut: -s makes sense only with -f or -F

function                                             old     new   delta
static._op_on_field                                   31      32      +1
.rodata                                           105659  105598     -61
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 1/-61)             Total: -60 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2024-12-16 00:51:31 +01:00
parent 0bd84c9472
commit ee8b94acbf

View file

@ -330,15 +330,15 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
/* non-field (char or byte) cutting has some special handling */ /* non-field (char or byte) cutting has some special handling */
if (!(opt & (OPT_FIELDS|OPT_REGEX))) { if (!(opt & (OPT_FIELDS|OPT_REGEX))) {
static const char _op_on_field[] ALIGN1 = " only when operating on fields"; static const char _op_on_field[] ALIGN1 = " makes sense only with -f"IF_FEATURE_CUT_REGEX(" or -F");
if (opt & OPT_SUPPRESS) { if (opt & OPT_SUPPRESS) {
bb_error_msg_and_die bb_error_msg_and_die
("suppressing non-delimited lines makes sense%s", _op_on_field); ("-s%s", _op_on_field);
} }
if (opt & OPT_DELIM) { if (opt & OPT_DELIM) {
bb_error_msg_and_die bb_error_msg_and_die
("a delimiter may be specified%s", _op_on_field); ("-d DELIM%s", _op_on_field);
} }
} }