coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

coreutils/src/logname.c (17 lines, 328 B) -rw-r--r-- blame download

012345678910111213141516
// logname.c, version 1.0.1
// OMKOV coreutils implementation of POSIX logname
// Copyright (C) 2020, Jakob Wakeling
// MIT Licence

#include "util/error.h"

#include <unistd.h>

#include <stdio.h>

int main(void) {
	register char *login = getlogin();
	if (!login) { error(1, "%s", serr()); }
	else { puts(login); } return 0;
}