Patch below:
>From 8ce9c281e07f7d61e2d0c555b9e91bc719b1fbb0 Mon Sep 17 00:00:00 2001
From: Hiltjo Posthuma <[email protected]>
Date: Thu, 31 Jul 2025 14:26:56 +0200
Subject: [PATCH 2/4] xargs: fix hang with -s option if argument doesn't fit
and cannot be resolved
Reproduce:
printf '12345 1234567890 12345' | ./xargs -t -s 5 echo
printf '12345 1234567890 12345' | ./xargs -t -x -n 1 -s 15 echo
There might still be further work needed for example this behaves differently
compared to GNU xargs:
printf '1234567890 12345' | xargs -t -x -s 20 echo
---
xargs.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/xargs.c b/xargs.c
index d9b2d98..3035bda 100644
--- a/xargs.c
+++ b/xargs.c
@@ -257,11 +257,8 @@ main(int argc, char *argv[])
while (leftover || (arg = poparg())) {
arglen = strlen(arg);
if (argsz + arglen >= argmaxsz || i >= NARGS - 1) {
- if (arglen >= argmaxsz) {
- weprintf("insufficient argument
space\n");
- if (xflag)
- exit(1);
- }
+ if (xflag || arglen >= argmaxsz || leftover)
+ eprintf("insufficient argument
space\n");
leftover = 1;
break;
}
--
2.50.1