From 851930b82dec1ac45cfb68c8d2958df947a4442e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 14 Jun 2018 14:50:02 -0500 Subject: Fix cut -DF as awk replacement by not matching delimiterless lines with -D --- toys/posix/cut.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toys/posix/cut.c b/toys/posix/cut.c index f61073f1..83582aaa 100644 --- a/toys/posix/cut.c +++ b/toys/posix/cut.c @@ -29,7 +29,7 @@ config CUT -c select UTF-8 characters -C select unicode columns -d use DELIM (default is TAB for -f, run of whitespace for -F) - -D Don't sort/collate selections + -D Don't sort/collate selections or match -fF lines without delimiter -f select fields (words) separated by single DELIM character -F select fields separated by DELIM regex -O output delimiter (default one space for -F, input delim for -f) @@ -155,6 +155,7 @@ static void cut_line(char **pline, long len) // If we never encountered even one separator, print whole line (posix!) if (!j && end == start) { + if (toys.optflags&FLAG_D) break; if (toys.optflags&FLAG_s) return; fwrite(line, len, 1, stdout); break; -- cgit v1.2.3