logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 474048430bfc18dc9369905417390b8c386d3417
parent 204bba2049c77c717782e4641b2c9b1177876e85
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 29 May 2025 13:38:54 +0200

cmd/printf: skip leading double-dash when there is multiple arguments

Diffstat:

Mcmd/printf.c6++++++
Mtest-cmd/printf.sh5++++-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/cmd/printf.c b/cmd/printf.c @@ -169,6 +169,12 @@ main(int argc, char *argv[]) argc--; argv++; + if(argc > 1 && strcmp("--", *argv) == 0) + { + argc--; + argv++; + } + if(argc < 1) { usage(); diff --git a/test-cmd/printf.sh b/test-cmd/printf.sh @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> # SPDX-License-Identifier: MPL-2.0 -plans=31 +plans=33 WD="$(dirname "$0")/../" target="${WD}/cmd/printf" . "${WD}/test-cmd/tap.sh" @@ -58,3 +58,6 @@ t_args nofmtconv 'foobar t_args nofmtconv_caret 'foo bar' 'foo \cHbar' t_args precision_s 'abcde' '%.5s' abcdefghijklmnopqrstuvwxyz + +t_args nofmt_doubledash '--' '--' +t_args doubledash_fmt '10.000000' '--' '%f' 10