summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/uname/uname.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/bin/uname/uname.c b/bin/uname/uname.c
index f648f92..3efd037 100644
--- a/bin/uname/uname.c
+++ b/bin/uname/uname.c
@@ -45,6 +45,7 @@ int main(int argc, char **argv) {
bool mflag, nflag, oflag, rflag, sflag, vflag;
mflag = nflag = oflag = rflag = sflag = vflag = false;
char ch;
+ bool space = false;
while ((ch = getopt(argc, argv, "amnorsv")) != -1) {
switch (ch) {
@@ -84,22 +85,27 @@ int main(int argc, char **argv) {
}
if (sflag) {
- printf("%s ", sysinfo.sysname);
+ printf("%s", sysinfo.sysname);
+ space = true;
}
if (nflag) {
- printf("%s ", sysinfo.nodename);
+ printf("%s%s", (space ? " " : ""), sysinfo.nodename);
+ space = true;
}
if (rflag) {
- printf("%s ", sysinfo.release);
+ printf("%s%s", (space ? " " : ""), sysinfo.release);
+ space = true;
}
if (vflag) {
- printf("%s ", sysinfo.version);
+ printf("%s%s", (space ? " " : ""), sysinfo.version);
+ space = true;
}
if (mflag) {
- printf("%s ", sysinfo.machine);
+ printf("%s%s", (space ? " " : ""), sysinfo.machine);
+ space = true;
}
if (oflag) {
- printf("%s ", sysinfo.sysname);
+ printf("%s%s", (space ? " " : ""), sysinfo.sysname);
}
printf("\n");