[PATCH] Add logname(1)

From: Brandon Mulcahy <brandon_AT_jangler.info>
Date: Thu, 16 Oct 2014 17:15:16 -0400

---
 Makefile  |  1 +
 logname.1 |  8 ++++++++
 logname.c | 20 ++++++++++++++++++++
 3 files changed, 29 insertions(+)
 create mode 100644 logname.1
 create mode 100644 logname.c
diff --git a/Makefile b/Makefile
index 6f995be..2f0ba53 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -57,6 +57,7 @@ SRC = \
 	head.c     \
 	hostname.c \
 	kill.c     \
+	logname.c  \
 	ln.c       \
 	ls.c       \
 	md5sum.c   \
diff --git a/logname.1 b/logname.1
new file mode 100644
index 0000000..0eebacf
--- /dev/null
+++ b/logname.1
_AT_@ -0,0 +1,8 @@
+.TH LOGNAME 1 sbase\-VERSION
+.SH NAME
+logname \- return the user's login name
+.SH SYNOPSIS
+.B logname
+.SH DESCRIPTION
+.B logname
+prints the login name of the current user.
diff --git a/logname.c b/logname.c
new file mode 100644
index 0000000..aa6357f
--- /dev/null
+++ b/logname.c
_AT_@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <unistd.h>
+#include "util.h"
+
+int
+main(int argc, char *argv[])
+{
+	char *login;
+
+	if (argc != 1)
+		eprintf("usage: %s\n", argv[0]);
+
+	if ((login = getlogin()))
+		printf("%s\n", login);
+	else
+		/* perror would say "No such file or directory" */
+		eprintf("%s: no login name\n", argv[0]);
+
+	return 0;
+}
-- 
2.1.2
--ibTvN161/egqYuK8--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Thu Oct 16 2014 - 23:36:08 CEST