commit 2b3baec7765435fa0ac6130c0cc4b8525f3f11e2
parent 41fac48fb081a1252c19db70535c7e8094c9058b
Author: qorg11 <qorg@vxempire.xyz>
Date: Fri, 21 Aug 2020 09:38:40 +0200
In GNU's uname(1) if you pass no arguments it prints the kernel name
so mine does that too.
TODO: print operating system name in -a and in the useless flag -v,
posix says it should be like that
Diffstat:
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/uname.c b/src/uname.c
@@ -11,7 +11,11 @@ main(int argc, char *argv[])
int node_name = 0;
int kernel_release = 0;
int kernel_name = 0;
+ int operating_system = 0;
+ int nothing = 0;
struct utsname kernel_info;
+ if(argc == 1)
+ nothing = 1;
while((c = getopt(argc, argv, "amnrsv")) != -1)
{
switch(c)
@@ -21,17 +25,20 @@ main(int argc, char *argv[])
case 'n': node_name = 1; break;
case 'r': kernel_release = 1; break;
case 's': kernel_name = 1; break;
+ case 'v': operating_system = 1; break;
+
}
}
uname(&kernel_info);
if(all)
{
- printf("%s %s %s %s %s\n",
+ printf("%s %s %s %s %s %s\n",
kernel_info.machine,
kernel_info.nodename,
kernel_info.release,
kernel_info.sysname,
- kernel_info.version);
+ kernel_info.version,
+ kernel_info.machine);
}
else{
if(machine)
@@ -40,10 +47,12 @@ main(int argc, char *argv[])
printf("%s ",kernel_info.nodename);
if(kernel_release)
printf("%s ",kernel_info.release);
- if(kernel_name)
+ if(kernel_name || nothing)
printf("%s ",kernel_info.sysname);
printf("\n");
+
}
+
return 0;
}