summaryrefslogtreecommitdiff
path: root/src/uname.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-10-12 01:52:24 +0000
committerJim Meyering <jim@meyering.net>1993-10-12 01:52:24 +0000
commit87fa23e6417d7d1938b72e872d779ae7225a5aa4 (patch)
tree0fcc68f9cdf7315d09d5836df0f261e3d6b8c13a /src/uname.c
parentf12b53b2ce8f0bb0dd28a290f9b27490ef4599a9 (diff)
downloadcoreutils-87fa23e6417d7d1938b72e872d779ae7225a5aa4.tar.xz
merge with 1.8.1b
Diffstat (limited to 'src/uname.c')
-rw-r--r--src/uname.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/uname.c b/src/uname.c
index c247aecdd..366e1e34a 100644
--- a/src/uname.c
+++ b/src/uname.c
@@ -32,7 +32,9 @@
#include <sys/types.h>
#include <sys/utsname.h>
#include <getopt.h>
+
#include "system.h"
+#include "version.h"
void error ();
@@ -61,13 +63,20 @@ static unsigned char toprint;
/* The name this program was run with, for error messages. */
char *program_name;
+/* If non-zero, display usage information and exit. */
+static int show_help;
+
+/* If non-zero, print the version on standard output and exit. */
+static int show_version;
+
static struct option const long_options[] =
{
- {"sysname", no_argument, NULL, 's'},
+ {"help", no_argument, &show_help, 1},
+ {"machine", no_argument, NULL, 'm'},
{"nodename", no_argument, NULL, 'n'},
{"release", no_argument, NULL, 'r'},
- {"version", no_argument, NULL, 'v'},
- {"machine", no_argument, NULL, 'm'},
+ {"sysname", no_argument, NULL, 's'},
+ {"version", no_argument, &show_version, 1},
{"all", no_argument, NULL, 'a'},
{NULL, 0, NULL, 0}
};
@@ -88,30 +97,48 @@ main (argc, argv)
{
switch (c)
{
+ case 0:
+ break;
+
case 's':
toprint |= PRINT_SYSNAME;
break;
+
case 'n':
toprint |= PRINT_NODENAME;
break;
+
case 'r':
toprint |= PRINT_RELEASE;
break;
+
case 'v':
toprint |= PRINT_VERSION;
break;
+
case 'm':
toprint |= PRINT_MACHINE;
break;
+
case 'a':
toprint = PRINT_SYSNAME | PRINT_NODENAME | PRINT_RELEASE |
PRINT_VERSION | PRINT_MACHINE;
break;
+
default:
usage ();
}
}
+ if (show_version)
+ {
+ printf ("%s\n", version_string);
+ exit (0);
+ }
+
+ if (show_help)
+ usage ();
+
if (optind != argc)
usage ();