xargs: fix hang with -s option if argument doesn't fit and cannot be resolved - sbase - suckless unix tools
 (HTM) git clone git://git.suckless.org/sbase
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 7c3ccc8659099199f1b3c24e0c534c1795c88a13
 (DIR) parent f63f0d7cdfdaa8bf8b6ff5e10fafb75c0f53ffb0
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Thu, 31 Jul 2025 15:30:00 +0200
       
       xargs: fix hang with -s option if argument doesn't fit and cannot be resolved
       
       Patch below:
       
       From 8ce9c281e07f7d61e2d0c555b9e91bc719b1fbb0 Mon Sep 17 00:00:00 2001
       From: Hiltjo Posthuma <hiltjo@codemadness.org>
       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
       
       Diffstat:
         M xargs.c                             |       7 ++-----
       
       1 file changed, 2 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git 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;
                                }