logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 281599280ffac7e38e6b53b11f493aad214769e9
parent d7e9a65afb03a7603f49c8ca5c1ac0495a0addbf
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 11 Aug 2023 23:50:20 +0200

cmd/cat: Add -u option for POSIX compat

Diffstat:

Mcmd/cat.110++++------
Mcmd/cat.c7+++++++
2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/cmd/cat.1 b/cmd/cat.1 @@ -1,5 +1,5 @@ .\" Collection of Unix tools, comparable to coreutils -.\" Copyright 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +.\" Copyright 2017-2023 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> .\" SPDX-License-Identifier: MPL-2.0 .Dd 2022-02-13 .Dt CAT 1 @@ -9,6 +9,7 @@ .Nd concatenate files .Sh SYNOPSIS .Nm +.Op Fl u .Op Ar files ... .Sh DESCRIPTION .Nm @@ -20,6 +21,8 @@ If no is given, .Nm reads from the standard input. +.Sh OPTIONS +.Fl u is ignored, present only for POSIX compatibility. .Sh EXIT STATUS .Ex -std .Sh STANDARDS @@ -29,8 +32,3 @@ is mostly compliant with the specification. .Sh AUTHORS .An Haelwenn (lanodan) Monnier Aq Mt contact@hacktivis.me -.Sh BUGS -.Nm -lacks the -.Fl u -option, this is mostly intended but it means a lack of unbuffered read/writes. diff --git a/cmd/cat.c b/cmd/cat.c @@ -73,6 +73,13 @@ main(int argc, char *argv[]) return concat(0, "<stdin>"); } + // For POSIX compatibility + if(strncmp(argv[1], "-u", 3) == 0) + { + argc--; + argv++; + } + for(int argi = 1; argi < argc; argi++) { if(strncmp(argv[argi], "-", 2) == 0)