[hackers] [sbase] Add logname(1) || Brandon Mulcahy

From: <git_AT_suckless.org>
Date: Fri, 17 Oct 2014 16:36:31 +0200

commit 7a73da6864a5f3c382b38d80ae590bb0fc85fcd0
Author: Brandon Mulcahy <brandon_AT_jangler.info>
Date: Thu Oct 16 17:15:16 2014 -0400

    Add logname(1)

diff --git a/Makefile b/Makefile
index 5ff507e..70f206c 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -59,6 +59,7 @@ SRC = \
         kill.c \
         link.c \
         ln.c \
+ logname.c \
         ls.c \
         md5sum.c \
         mkdir.c \
diff --git a/README b/README
index 242b99b..8eba0fa 100644
--- a/README
+++ b/README
_AT_@ -36,6 +36,7 @@ hostname
 kill
 link
 ln
+logname
 ls
 md5sum
 mkdir
diff --git a/TODO b/TODO
index 0db8e6c..7c2f889 100644
--- a/TODO
+++ b/TODO
_AT_@ -13,7 +13,6 @@ find
 getconf
 join
 logger
-logname
 od
 patch
 pathchk
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..7d6da8b
--- /dev/null
+++ b/logname.c
_AT_@ -0,0 +1,20 @@
+/* See LICENSE file for copyright and license details. */
+#include <stdio.h>
+#include <unistd.h>
+
+#include "util.h"
+
+int
+main(int argc, char *argv[])
+{
+ char *login;
+
+ argv0 = argv[0];
+ if (argc != 1)
+ eprintf("usage: %s\n", argv0);
+ if ((login = getlogin()))
+ printf("%s\n", login);
+ else
+ eprintf("%s: no login name\n", argv0);
+ return 0;
+}
Received on Fri Oct 17 2014 - 16:36:31 CEST

This archive was generated by hypermail 2.3.0 : Fri Oct 17 2014 - 16:48:21 CEST