[git commit] cut: shorten error messages on bad syntax

Denys Vlasenko vda.linux at googlemail.com
Sun Dec 15 23:53:51 UTC 2024


commit: https://git.busybox.net/busybox/commit/?id=ee8b94acbf9ac9a6a48831a244cfef897affe82e
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

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 at googlemail.com>
---
 coreutils/cut.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/coreutils/cut.c b/coreutils/cut.c
index 0913c4b68..af2fd9fd4 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -330,15 +330,15 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
 
 	/* non-field (char or byte) cutting has some special handling */
 	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) {
 			bb_error_msg_and_die
-				("suppressing non-delimited lines makes sense%s", _op_on_field);
+				("-s%s", _op_on_field);
 		}
 		if (opt & OPT_DELIM) {
 			bb_error_msg_and_die
-				("a delimiter may be specified%s", _op_on_field);
+				("-d DELIM%s", _op_on_field);
 		}
 	}
 


More information about the busybox-cvs mailing list