[hackers] [sbase] extra uname spaces confuse scripts || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Thu, 9 Jun 2011 01:40:43 +0200 (CEST)

changeset: 61:5a597358bf4c
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Thu Jun 09 00:40:23 2011 +0100
files: uname.c
description:
extra uname spaces confuse scripts

diff -r b439f967b5c2 -r 5a597358bf4c uname.c
--- a/uname.c Wed Jun 08 21:30:33 2011 +0100
+++ b/uname.c Thu Jun 09 00:40:23 2011 +0100
@@ -6,6 +6,8 @@
 #include <sys/utsname.h>
 #include "util.h"
 
+static void print(const char *);
+
 int
 main(int argc, char *argv[])
 {
@@ -44,15 +46,26 @@
                 eprintf("uname:");
 
         if(sflag || !(nflag || rflag || vflag || mflag))
- printf("%s ", u.sysname);
+ print(u.sysname);
         if(nflag)
- printf("%s ", u.nodename);
+ print(u.nodename);
         if(rflag)
- printf("%s ", u.release);
+ print(u.release);
         if(vflag)
- printf("%s ", u.version);
+ print(u.version);
         if(mflag)
- printf("%s ", u.machine);
+ print(u.machine);
         putchar('\n');
         return EXIT_SUCCESS;
 }
+
+void
+print(const char *s)
+{
+ static bool first = true;
+
+ if(!first)
+ putchar(' ');
+ fputs(s, stdout);
+ first = false;
+}
Received on Thu Jun 09 2011 - 01:40:43 CEST

This archive was generated by hypermail 2.2.0 : Thu Jun 09 2011 - 01:48:05 CEST