From e3bc4a02e2867722f45190e333078384a79554c1 Mon Sep 17 00:00:00 2001 From: Mid Favila Date: Sun, 21 Nov 2021 16:37:11 -0400 Subject: [PATCH] Add TODO and SUS-compliant yes. --- TODO | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/echo.1 | 54 ++++++++++++++++++++++++++++++++ doc/yes.1 | 34 ++++++++++++++++++++ src/yes.c | 13 ++++++++ 4 files changed, 192 insertions(+) create mode 100644 TODO create mode 100644 doc/echo.1 create mode 100644 doc/yes.1 create mode 100644 src/yes.c diff --git a/TODO b/TODO new file mode 100644 index 0000000..00e796a --- /dev/null +++ b/TODO @@ -0,0 +1,91 @@ +Write a Makefile. +Add octal escape support to echo. +Rework yes(1) to buffer input. This achieves greater throughput per system call. + +Write the following utilities: + ar + at/atd + basename + batch(?) + bc + cal + cat + chgrp + chmod + chownn + cksum + cmp + comm + compress(?) + cp + crond/crontab + csplit + cut + dd + df + diff + dirname + du + ed/x + expand(?) + expr + file + find + fold + fuser + grep + head + iconv + id + join + kill + link(?) + ln + locale + localedef + logname + lp(?) + ls + mesg + mkdir + mkfifo + mknod + mktemp + more + mv + newgrp(?) + nice + nl + paste + pathchk(?) + pax + printf + ps + pwd + renice + rm + rmdir + sed + sh + sleep + sort + split + strings + tabs + tail + talk(?) + tee + test + touch + tput + tr + true + tsort + uname + uncompress(?) + unexpand + uniq + wc + who + write(?) + xargs diff --git a/doc/echo.1 b/doc/echo.1 new file mode 100644 index 0000000..a1aed2e --- /dev/null +++ b/doc/echo.1 @@ -0,0 +1,54 @@ +.TH echo 1 2021-11-21 mp-utils Userland + +.SH NAME +echo \- Print argv to stdout. +.PP +.SH SYNOPSIS +.PP +Print the provided arguments to stdout while applying +.SM +SUS +backslash escapes. +.SH DESCRIPTION +.PP +Echo is a standard Unix tool that accepts input from the user and prints it to stdout while applying minimal or no formatting. +.SH OPTIONS +.PP +This implementation of echo accepts no arguments. +.SH ENVIRONMENT +This implementation of echo requires a C89 compiler. +.SH FILES +/usr/src/mp-utils/src/echo.c +.SH CONFORMING TO +.PP +.SM +POSIX +2017, +.SM +SUS +3 +.SH NOTES +.PP +Including the following backslash-escapes modifies echo's behavior. + +\\a \- Print a BEL. + +\\b \- Print a backspace. + +\\f \- Print a form-feed. + +\\f \- Print a newline. + +\\r \- Print a carriage return. + +\\t \- Print a tabulation. + +\\v \- Print a vertical tabulation. + +\\c \- Suppress the trailing newline and ignore further input. + +.SH BUGS +.PP +Currently, \\0 (octal) escapes have not been implemented. +.SH SEE ALSO +echo(1p), printf(1) diff --git a/doc/yes.1 b/doc/yes.1 new file mode 100644 index 0000000..36a12f3 --- /dev/null +++ b/doc/yes.1 @@ -0,0 +1,34 @@ +.TH yes 1 2021-11-21 mp-utils Userland + +.SH NAME +yes \- print to stdout forever +.PP +.SH SYNOPSIS +.PP +Print the provided string to stdout forever. +.SH DESCRIPTION +.PP +Yes is a standard Unix tool that accepts input from the user and prints it to stdout repeatedly, or y when no input is provided. +.SH OPTIONS +.PP +This implementation of yes accepts no arguments. +.SH ENVIRONMENT +This implementation of yes requires a C89 compiler. +.SH FILES +/usr/src/mp-utils/src/yes.c +.SH CONFORMING TO +.PP +.SM +POSIX +2017, +.SM +SUS +3 +.SH NOTES +.PP +None. +.SH BUGS +.PP +None known. +.SH SEE ALSO +yes(1p) \ No newline at end of file diff --git a/src/yes.c b/src/yes.c new file mode 100644 index 0000000..97b6c85 --- /dev/null +++ b/src/yes.c @@ -0,0 +1,13 @@ +#include "common.h" + +int main(int argc, char **argv) + { + if(argc > 1) + while(1) + puts(argv[1]); + else + while(1) + puts("y"); + + return 0; + }