bore

basic core utilities (PD)
git clone git://bvnf.space/bore.git
Log | Files | Refs | README

commit 530b47040cddd955142feaaeec150737452b1723
parent 111c4e6b335f1c90be53cac502466c9adb8df797
Author: phoebos <ben@bvnf.space>
Date:   Sun, 10 Oct 2021 00:30:54 +0100

tty: add

Diffstat:
MMakefile | 1+
MPROGRESS | 2+-
Atty.c | 18++++++++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -10,6 +10,7 @@ BINS = \ mkdir \ tee \ true \ + tty \ wc \ CC = cc diff --git a/PROGRESS b/PROGRESS @@ -43,7 +43,7 @@ [ ] touch [ ] tr [x] true -[ ] tty +[x] tty [ ] uname [ ] uudecode [ ] uuencode diff --git a/tty.c b/tty.c @@ -0,0 +1,18 @@ +#include <errno.h> +#include <stdio.h> +#include <unistd.h> + +int +main(void) { + char *tty = ttyname(0); + if (tty == NULL) { + if (errno != ENOTTY) { + perror("tty"); + return 2; + } + printf("not a tty\n"); + return 1; + } + printf("%s\n", tty); + return 0; +}