[hackers] [sbase] Adding the yes(1) command. || Christoph Lohmann

From: <hg_AT_suckless.org>
Date: Mon, 23 Apr 2012 16:27:48 +0200 (CEST)

changeset: 109:d6ea66d9cc59
tag: tip
user: Christoph Lohmann <20h_AT_r-36.net>
date: Mon Apr 23 16:27:40 2012 +0200
files: Makefile TODO yes.1 yes.c
description:
Adding the yes(1) command.


diff -r a2bcdadccf77 -r d6ea66d9cc59 Makefile
--- a/Makefile Mon Apr 23 15:50:47 2012 +0200
+++ b/Makefile Mon Apr 23 16:27:40 2012 +0200
_AT_@ -52,7 +52,8 @@
         tty.c \
         uname.c \
         seq.c \
- wc.c
+ wc.c \
+ yes.c
 
 OBJ = $(SRC:.c=.o) $(LIB)
 BIN = $(SRC:.c=)
diff -r a2bcdadccf77 -r d6ea66d9cc59 TODO
--- a/TODO Mon Apr 23 15:50:47 2012 +0200
+++ b/TODO Mon Apr 23 16:27:40 2012 +0200
_AT_@ -60,4 +60,3 @@
 
 who
 
-yes [string]
diff -r a2bcdadccf77 -r d6ea66d9cc59 yes.1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yes.1 Mon Apr 23 16:27:40 2012 +0200
_AT_@ -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.
+
diff -r a2bcdadccf77 -r d6ea66d9cc59 yes.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yes.c Mon Apr 23 16:27:40 2012 +0200
_AT_@ -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;
+}
+
Received on Mon Apr 23 2012 - 16:27:48 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 23 2012 - 16:36:08 CEST