Add logname(1)
This commit is contained in:
parent
314885836c
commit
7a73da6864
1
Makefile
1
Makefile
@ -59,6 +59,7 @@ SRC = \
|
||||
kill.c \
|
||||
link.c \
|
||||
ln.c \
|
||||
logname.c \
|
||||
ls.c \
|
||||
md5sum.c \
|
||||
mkdir.c \
|
||||
|
8
logname.1
Normal file
8
logname.1
Normal file
@ -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.
|
20
logname.c
Normal file
20
logname.c
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user