From 5ffbe50b5df30619cd4b36471103be4b21754a25 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 30 Dec 2014 11:37:22 +0000 Subject: [PATCH] utils: Import yes from ELKS sh-utils and ANSIfy --- Applications/util/Makefile | 4 +++- Applications/util/yes.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Applications/util/yes.c diff --git a/Applications/util/Makefile b/Applications/util/Makefile index 8308a8bb..5cebabad 100644 --- a/Applications/util/Makefile +++ b/Applications/util/Makefile @@ -82,12 +82,14 @@ SRCS = banner.c \ tr.c \ true.c \ umount.c \ + uname.c \ uniq.c \ uud.c \ uue.c \ wc.c \ which.c \ - whoami.c + whoami.c \ + yes.c OBJS = $(SRCS:.c=.rel) diff --git a/Applications/util/yes.c b/Applications/util/yes.c new file mode 100644 index 00000000..f3cea7b7 --- /dev/null +++ b/Applications/util/yes.c @@ -0,0 +1,25 @@ +/* yes 1.4 - print 'y' or argv[1] continuously. Author: Kees J. Bot + * 15 Apr 1989 + */ +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char *yes; + int n; + static char y[] = "y"; + + yes = argc == 1 ? y : argv[1]; + + n = strlen(yes); + + yes[n++] = '\n'; + + while (write(1, yes, n) != -1) + /* Do nothing */; + + exit(1); +} -- 2.34.1