RE: [PATCH] join: new applet

Morgan via busybox <[email protected]> Mon, 6 Jul 2026 10:32:55 +1000
Newsgroups gmane.linux.busybox
Message-ID <[email protected]>
From: busybox <[email protected]> On Behalf Of Ron Yorston via
busybox
Sent: Monday, 6 July 2026 00:56
> [...]
>
> +	n = 0;
> +	if (sep != '\0') {  /* single-character split */
> +		while ((s1 = strchr(ps, sep)) != NULL) {
> +			sl[n] = ps;
> +			*s1 = '\0';
> +			ps = s1 + 1;
> +			n++;
> +		}
> +		/* Add the last field */
> +		sl[n] = ps;
> +		n++;
> +		curr->fieldcount = n;

Looks like I missed a return here to stop re-parsing when reworking that
function:

+		return;

> +	}
> +	/* default split: skip the initial whitespace and then any run
> +	   of non-whitespace characters is a field */
>
> [...]
>
> +
> +testing "join -o for fields to print, -e for empty fields" \
> +	"join -a 1 -a 2 -e --- -o 0,1.2,2.2 input -" \
> +	"a 123 abc\nb 456 ---\nc 789 def\nd --- ghi\n" \
> +	"a 123\nb 456\nc 789\n" \
> +	"a abc\nc def\nd ghi\n"
> +
> +testing "join -o works for combinatorial" \
> +	"join -o 0,1.2,2.2 input -" \
> +	"a 123 abc\na 123 def\na 456 abc\na 456 def\n" \
> +	"a 123\na 456\n" \
> +	"a abc\na def\n"

And so we can add this test:

+testing "join -t works" \
+	"join -t A input -" \
+	"item 1A123Aabc\nitem 2A456Adef\n" \
+	"item 1A123\nitem 2A456\n" \
+	"item 1Aabc\nitem 2Adef\n"

> +
> +exit $FAILCOUNT
> --
> 2.55.0
>
> _______________________________________________
> busybox mailing list
> [email protected]
> https://lists.busybox.net/mailman/listinfo/busybox