Adding the yes(1) command.

This commit is contained in:
Christoph Lohmann 2012-04-23 16:27:40 +02:00
parent f75d7a47ff
commit 120d817920
4 changed files with 56 additions and 2 deletions

View File

@ -52,7 +52,8 @@ SRC = \
tty.c \
uname.c \
seq.c \
wc.c
wc.c \
yes.c
OBJ = $(SRC:.c=.o) $(LIB)
BIN = $(SRC:.c=)

1
TODO
View File

@ -60,4 +60,3 @@ unlink file
who
yes [string]

10
yes.1 Normal file
View File

@ -0,0 +1,10 @@
.TH YES 1 sbase\-VERSION
.SH NAME
yes \- output a string repeatedly
.SH SYNOPSIS
.B yes
.RB [ string ... ]
.SH DESCRIPTION
.B yes
will repeatedly output 'y' or the strings specified.

44
yes.c Normal file
View File

@ -0,0 +1,44 @@
/* See LICENSE file for copyright and license details. */
#include <unistd.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include "arg.h"
#include "util.h"
char *argv0;
void
usage(void)
{
eprintf("usage: %s [string ...]\n", basename(argv0));
}
int
main(int argc, char *argv[])
{
int i;
ARGBEGIN {
default:
usage();
} ARGEND;
if (!argc) {
for(;;)
puts("y");
}
for (;;) {
for (i = 0; i < argc; i++) {
fputs(argv[i], stdout);
if (argv[i+1] != NULL)
fputs(" ", stdout);
}
fputs("\n", stdout);
}
return EXIT_SUCCESS;
}