logo

utils-std

Collection of commonly available Unix tools
commit: 5893b843e937742761c928f8f208eec3c167afb1
parent e4244694098da65e31b7c342c2c217cb1123110b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 23 Aug 2024 04:55:13 +0200

cmd/echo: don't increase arg_len on empty strings

Diffstat:

Mcmd/echo.c8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/cmd/echo.c b/cmd/echo.c @@ -28,9 +28,11 @@ main(int argc, char *argv[]) { size_t len = strlen(argv[i]); - if(len > 0) argv[i][len] = (i + 1) == argc ? '\n' : ' '; - - arg_len += len + 1; // str + space|newline + if(len > 0) + { + argv[i][len] = (i + 1) == argc ? '\n' : ' '; + arg_len += len + 1; // str + space|newline + } } if(arg_len == 0)