summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKiyoshi Aman <kiyoshi.aman+adelie@gmail.com>2019-07-21 06:48:19 -0500
committerKiyoshi Aman <kiyoshi.aman+adelie@gmail.com>2019-07-21 06:48:19 -0500
commit8158ef186bf16307b6ed2c329cf008064c6ba868 (patch)
treea2e0597eae562f60e4bf08edb4bf22e6bb6ae13f
parent48809202858c5b24383b3d8622f0130679971fa4 (diff)
downloaduserland-8158ef186bf16307b6ed2c329cf008064c6ba868.tar.gz
userland-8158ef186bf16307b6ed2c329cf008064c6ba868.tar.bz2
userland-8158ef186bf16307b6ed2c329cf008064c6ba868.tar.xz
userland-8158ef186bf16307b6ed2c329cf008064c6ba868.zip
bin/uname: fix nonstandard behaviour
-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");