Audit logname(1)

1) Add usage().
2) Idiomatic argv0-setter. We don't use arg.h, as we do not process
   flags or arguments.
3) Remove program-name from eprintf-call. This is done in the eprintf-
   function itself when the DEBUG-define is set.
   We'll activate it by default later.
4) Add empty line before return.
This commit is contained in:
FRIGN 2015-03-17 00:44:18 +01:00
parent fbda47b964
commit 683d108387
2 changed files with 14 additions and 5 deletions

2
README
View File

@ -41,7 +41,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
=*| link yes none =*| link yes none
=*| ln yes none =*| ln yes none
=*| logger yes none =*| logger yes none
=* logname yes none =*| logname yes none
= ls no (-C), -S, -f, -m, -s, -x = ls no (-C), -S, -f, -m, -s, -x
=*| md5sum non-posix none =*| md5sum non-posix none
=*| mkdir yes none =*| mkdir yes none

View File

@ -4,17 +4,26 @@
#include "util.h" #include "util.h"
static void
usage(void)
{
eprintf("usage: %s\n", argv0);
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
char *login; char *login;
argv0 = argv[0]; argv0 = argv[0], argc--, argv++;
if (argc != 1)
eprintf("usage: %s\n", argv0); if (argc)
usage();
if ((login = getlogin())) if ((login = getlogin()))
puts(login); puts(login);
else else
eprintf("%s: no login name\n", argv0); eprintf("no login name\n");
return 0; return 0;
} }