Author | Jamozed <[email protected]> |
Date | 2020-06-26 05:04:08 |
Commit | cf2d47a9c5ad467fc91a718517cb8b571eda75c1 |
Parent | ba7d1e07caa6a6caa403fd4668912e21fbc8d6ee |
yes: Add yes utility
Diffstat
M | CMakeLists.txt | | | 1 | + |
M | README.md | | | 1 | + |
A | man/yes.1 | | | 18 | ++++++++++++++++++ |
A | src/yes.c | | | 25 | +++++++++++++++++++++++++ |
4 files changed, 45 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e05d39..8cf8706 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,3 +16,4 @@ ADD_EXECUTABLE(dirname ${CMAKE_SOURCE_DIR}/src/dirname.c) ADD_EXECUTABLE(echo ${CMAKE_SOURCE_DIR}/src/echo.c) ADD_EXECUTABLE(false ${CMAKE_SOURCE_DIR}/src/false.c) ADD_EXECUTABLE(true ${CMAKE_SOURCE_DIR}/src/true.c) +ADD_EXECUTABLE(yes ${CMAKE_SOURCE_DIR}/src/yes.c) diff --git a/README.md b/README.md index 0ba8b2e..1378735 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ commonly found on UNIX-like systems. | echo | Write arguments to standard output | POSIX | | false | Return false value | POSIX | | true | Return true value | POSIX | +| yes | Output a string repeatedly | | ## Build Instructions diff --git a/man/yes.1 b/man/yes.1 new file mode 100644 index 0000000..dc77e8a --- /dev/null +++ b/man/yes.1 @@ -0,0 +1,18 @@ +.TH YES 1 2020-06-26 "OMKOV coreutils" "General Commands Manual" +.SH NAME +yes \(em output a string repeatedly +.SH SYNOPSYS +\fByes\fR [\fIstring\fR] +.SH DESCRIPTION +Repeatedly output \fIstring\fR, or 'y' if unspecified, to standard output. +.SH OPERANDS +The following operand is supported: +.TP +.I string +A string to be written to standard output. +.SH COPYRIGHT +.nf +Copyright (C) 2020, Jakob Wakeling +All rights reserved. +OMKOV Public Domain Licence (https://www.omkov.net/OLPD) +.fi diff --git a/src/yes.c b/src/yes.c new file mode 100644 index 0000000..8f8c342 --- /dev/null +++ b/src/yes.c @@ -0,0 +1,25 @@ +// yes.c, version 1.0.0 +// OMKOV coreutils implementation of yes +// Copyright (C) 2020, Jakob Wakeling +// All rights reserved. + +/* +OMKOV Public Domain Licence, version 1.0 + +Permission is hereby granted to deal with this software and its associated +documentation files without restriction. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT +HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. +*/ + +#include <stdio.h> + +int main(int argc, char *argv[]) { + if (argc == 1) for (;;) { fputc('y', stdout); fputc('\n', stdout); } + else for (;;) { puts(argv[1]); } return 0; +}