extra uname spaces confuse scripts

This commit is contained in:
Connor Lane Smith 2011-06-09 00:40:23 +01:00
parent ff97891dad
commit 17a81ace44

23
uname.c
View File

@ -6,6 +6,8 @@
#include <sys/utsname.h> #include <sys/utsname.h>
#include "util.h" #include "util.h"
static void print(const char *);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@ -44,15 +46,26 @@ main(int argc, char *argv[])
eprintf("uname:"); eprintf("uname:");
if(sflag || !(nflag || rflag || vflag || mflag)) if(sflag || !(nflag || rflag || vflag || mflag))
printf("%s ", u.sysname); print(u.sysname);
if(nflag) if(nflag)
printf("%s ", u.nodename); print(u.nodename);
if(rflag) if(rflag)
printf("%s ", u.release); print(u.release);
if(vflag) if(vflag)
printf("%s ", u.version); print(u.version);
if(mflag) if(mflag)
printf("%s ", u.machine); print(u.machine);
putchar('\n'); putchar('\n');
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
void
print(const char *s)
{
static bool first = true;
if(!first)
putchar(' ');
fputs(s, stdout);
first = false;
}