toaruos/apps/logname.c

23 lines
492 B
C
Raw Permalink Normal View History

/**
* @brief Display the user's name, as returned by getlogin()
*
* @copyright
2018-10-09 14:35:53 +03:00
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2018 K. Lange
*/
#include <unistd.h>
#include <stdio.h>
int main(int argc, char ** argv) {
char * name = getlogin();
if (!name) {
fprintf(stderr, "%s: failed to determine login name\n", argv[0]);
return 1;
}
fprintf(stdout, "%s\n", name);
return 0;
}