From 73cff35173dd75b0254ae7cf9098c32822859de0 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 16 Apr 2019 20:37:01 +0000 Subject: It builds! Tomorrow: skeletons for stage2, stage3 and runlevel scripts. --- src/misc/s6-linux-init-echo.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/misc/s6-linux-init-echo.c (limited to 'src/misc/s6-linux-init-echo.c') diff --git a/src/misc/s6-linux-init-echo.c b/src/misc/s6-linux-init-echo.c new file mode 100644 index 0000000..d39e649 --- /dev/null +++ b/src/misc/s6-linux-init-echo.c @@ -0,0 +1,39 @@ +/* ISC license. */ + +#include +#include +#include + +#define USAGE "s6-linux-init-echo [ -n ] [ -s sep ] args..." + +int main (int argc, char const *const *argv) +{ + char sep = ' ' ; + char donl = 1 ; + PROG = "s6-echo" ; + { + subgetopt_t l = SUBGETOPT_ZERO ; + for (;;) + { + int opt = subgetopt_r(argc, argv, "ns:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'n': donl = 0 ; break ; + case 's': sep = *l.arg ; break ; + default : strerr_dieusage(100, USAGE) ; + } + } + argc -= l.ind ; argv += l.ind ; + } + for ( ; *argv ; argv++) + if ((buffer_puts(buffer_1small, *argv) < 0) + || (argv[1] && (buffer_put(buffer_1small, &sep, 1) < 0))) + goto err ; + if (donl && (buffer_put(buffer_1small, "\n", 1) < 0)) goto err ; + if (!buffer_flush(buffer_1small)) goto err ; + return 0 ; + + err: + strerr_diefu1sys(111, "write to stdout") ; +} -- cgit v1.2.3