1
0
mirror of git://git.suckless.org/sbase synced 2024-12-26 00:42:35 +00:00
sbase/uname.c
stateless 7216a53a7e Remove unnecessary exit(1) in usage()
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2013-06-19 19:58:19 +02:00

65 lines
984 B
C

/* See LICENSE file for copyright and license details. */
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/utsname.h>
#include "util.h"
static void
usage(void)
{
eprintf("usage: %s [-amnrsv]\n", argv0);
}
int
main(int argc, char *argv[])
{
bool mflag = false;
bool nflag = false;
bool rflag = false;
bool sflag = false;
bool vflag = false;
struct utsname u;
ARGBEGIN {
case 'a':
mflag = nflag = rflag = sflag = vflag = true;
break;
case 'm':
mflag = true;
break;
case 'n':
nflag = true;
break;
case 'r':
rflag = true;
break;
case 's':
sflag = true;
break;
case 'v':
vflag = true;
break;
default:
usage();
} ARGEND;
if(uname(&u) == -1)
eprintf("uname:");
if(sflag || !(nflag || rflag || vflag || mflag))
putword(u.sysname);
if(nflag)
putword(u.nodename);
if(rflag)
putword(u.release);
if(vflag)
putword(u.version);
if(mflag)
putword(u.machine);
putchar('\n');
return 0;
}