sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 7a73da6864a5f3c382b38d80ae590bb0fc85fcd0
parent 314885836c091dfeb68232f50c8be862a381f265
Author: Brandon Mulcahy <brandon@jangler.info>
Date:   Thu, 16 Oct 2014 17:15:16 -0400

Add logname(1)

Diffstat:
Makefile | 1+
README | 1+
TODO | 1-
logname.1 | 8++++++++
logname.c | 20++++++++++++++++++++
5 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -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 @@ -36,6 +36,7 @@ hostname kill link ln +logname ls md5sum mkdir diff --git a/TODO b/TODO @@ -13,7 +13,6 @@ find getconf join logger -logname od patch pathchk diff --git a/logname.1 b/logname.1 @@ -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 @@ -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; +}