`uname`!
[lab.git] / logname.c
blobac9c252af2b9bda396849d43e6e5135829d85d76
1 /* `logname.c` - return the user's login name
2 Copyright (c) 2022, Alan Potteiger
3 See `LICENSE` for copyright and license details */
5 #define _POSIX_C_SOURCE 200809L
7 #include <stdio.h>
8 #include <unistd.h>
10 static const char *usage = {
11 "usage: logname\n"
14 int
15 main(int argc, char *argv[])
17 char *name;
19 name = getlogin();
20 if (name == NULL) {
21 fputs("logname: login name not set\n", stderr);
22 return 1;
25 puts(name);
26 return 0;