Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Sep 2023 16:38:00 GMT
From:      Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: d9d69a6f6fc1 - main - split: Improve GNU compatibility.
Message-ID:  <202309281638.38SGc02g090009@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=d9d69a6f6fc1f8d80df9ce6493e8ab9388781615

commit d9d69a6f6fc1f8d80df9ce6493e8ab9388781615
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-09-28 16:30:00 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-09-28 16:30:16 +0000

    split: Improve GNU compatibility.
    
    * Like GNU split, turn autoextend back on if given -a0.
    * Add a test case that verifies that -a<non-zero> turns autoextend off.
    * Add a test case that verifies that -a0 turns autoextend back on.
    
    Sponsored by:   Klara, Inc.
    Reviewed by:    christos, kevans
    Differential Revision:  https://reviews.freebsd.org/D42011
---
 usr.bin/split/split.c             |  7 ++++++-
 usr.bin/split/tests/split_test.sh | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c
index ba98d82b25c4..e246a0d4adfc 100644
--- a/usr.bin/split/split.c
+++ b/usr.bin/split/split.c
@@ -115,7 +115,12 @@ main(int argc, char **argv)
 				errx(EX_USAGE, "%s: suffix length is %s",
 				    optarg, errstr);
 			}
-			autosfx = false;
+			if (sufflen == 0) {
+				sufflen = 2;
+				autosfx = true;
+			} else {
+				autosfx = false;
+			}
 			break;
 		case 'b':		/* Byte count. */
 			if (expand_number(optarg, &bytecnt) != 0) {
diff --git a/usr.bin/split/tests/split_test.sh b/usr.bin/split/tests/split_test.sh
index c9b87c01618c..48065719055a 100755
--- a/usr.bin/split/tests/split_test.sh
+++ b/usr.bin/split/tests/split_test.sh
@@ -209,6 +209,23 @@ autoextend_body()
 	atf_check -o inline:"$((26*25+1))\n" cat xzaaa
 }
 
+atf_test_case noautoextend
+noautoextend_body()
+{
+	seq $((26*26)) >input
+	atf_check split -a2 -l1 input
+	atf_check -o inline:"$((26*26))\n" cat xzz
+}
+
+atf_test_case reautoextend
+reautoextend_body()
+{
+	seq $((26*25+1)) >input
+	atf_check split -a2 -a0 -l1 input
+	atf_check -o inline:"$((26*25))\n" cat xyz
+	atf_check -o inline:"$((26*25+1))\n" cat xzaaa
+}
+
 atf_test_case continue
 continue_body()
 {
@@ -249,6 +266,8 @@ atf_init_test_cases()
 	atf_add_test_case larger_suffix_length
 	atf_add_test_case pattern
 	atf_add_test_case autoextend
+	atf_add_test_case noautoextend
+	atf_add_test_case reautoextend
 	atf_add_test_case continue
 	atf_add_test_case undocumented_kludge
 	atf_add_test_case duplicate_linecount



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309281638.38SGc02g090009>