Hi Jim,
On Tue, Apr 03, 2007 at 12:23:32PM -0700, H. Peter Anvin wrote:
> Karel Zak wrote:
> >On Tue, Apr 03, 2007 at 05:56:49PM +0200, Matthias Koenig wrote:
> >>Hi,
> >>
> >>I noticed that /bin/arch has been removed in release 2.13-pre1.
> >>While this command is equivalent to uname -m, it is used by some
> >>old scripts. Any chance to keep this for compatibility reasons?
> >
> > Good point.
> >
> > Yes, I'd like to keep it. It seems that many people (include me :-)
> > use it. We (Red Hat) have tried to remove it from our distros, but
> > without success. I think maintain this tiny tool is without any
> > overhead.
>
> #!/bin/sh
> exec /bin/uname -m
>
> Either that, or just make uname detect a link to "arch".
What do you think about this idea? Is it possible to add the "arch"
command emulation to the "uname" command in a next coreutils release?
Please, see the following patch. Note, the patch doesn't include any
change to build system -- I'm not sure if automatically create the
link (/bin/arch -> /bin/uname) is a good idea, because almost all
people use old util-linux with the arch binary.
Karel
--- coreutils-6.9/src/uname.c.kzak 2007-03-18 22:36:43.000000000 +0100
+++ coreutils-6.9/src/uname.c 2007-06-05 11:57:58.000000000 +0200
@@ -155,6 +155,7 @@
main (int argc, char **argv)
{
int c;
+ char *basename;
static char const unknown[] = "unknown";
/* Mask indicating which elements to print. */
@@ -168,59 +169,69 @@
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "asnrvmpio", long_options, NULL)) != -1)
+ if ((basename = strrchr(program_name, '/')))
+ basename++;
+ else
+ basename = program_name;
+
+ if (strcmp(basename, "arch") == 0)
+ toprint = PRINT_MACHINE;
+ else
{
- switch (c)
+ while ((c = getopt_long (argc, argv, "asnrvmpio", long_options, NULL))
!= -1)
{
- case 'a':
- toprint = UINT_MAX;
- break;
+ switch (c)
+ {
+ case 'a':
+ toprint = UINT_MAX;
+ break;
- case 's':
- toprint |= PRINT_KERNEL_NAME;
- break;
+ case 's':
+ toprint |= PRINT_KERNEL_NAME;
+ break;
- case 'n':
- toprint |= PRINT_NODENAME;
- break;
+ case 'n':
+ toprint |= PRINT_NODENAME;
+ break;
- case 'r':
- toprint |= PRINT_KERNEL_RELEASE;
- break;
+ case 'r':
+ toprint |= PRINT_KERNEL_RELEASE;
+ break;
- case 'v':
- toprint |= PRINT_KERNEL_VERSION;
- break;
+ case 'v':
+ toprint |= PRINT_KERNEL_VERSION;
+ break;
- case 'm':
- toprint |= PRINT_MACHINE;
- break;
+ case 'm':
+ toprint |= PRINT_MACHINE;
+ break;
- case 'p':
- toprint |= PRINT_PROCESSOR;
- break;
+ case 'p':
+ toprint |= PRINT_PROCESSOR;
+ break;
- case 'i':
- toprint |= PRINT_HARDWARE_PLATFORM;
- break;
+ case 'i':
+ toprint |= PRINT_HARDWARE_PLATFORM;
+ break;
- case 'o':
- toprint |= PRINT_OPERATING_SYSTEM;
- break;
+ case 'o':
+ toprint |= PRINT_OPERATING_SYSTEM;
+ break;
- case_GETOPT_HELP_CHAR;
+ case_GETOPT_HELP_CHAR;
- case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
- default:
- usage (EXIT_FAILURE);
+ default:
+ usage (EXIT_FAILURE);
+ }
}
- }
- if (argc != optind)
- {
- error (0, 0, _("extra operand %s"), quote (argv[optind]));
- usage (EXIT_FAILURE);
+ if (argc != optind)
+ {
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
+ usage (EXIT_FAILURE);
+ }
}
if (toprint == 0)
--- coreutils-6.9/ChangeLog.kzak 2007-06-05 12:00:08.000000000 +0200
+++ coreutils-6.9/ChangeLog 2007-06-05 12:03:42.000000000 +0200
@@ -0,0 +1,4 @@
+2007-06-05 Karel Zak <[EMAIL PROTECTED]>
+ * src/uname.c: Add the arch command emulation when argv[0] is "arch"
+ (e.g symlink /bin/arch -> /bin/uname)
+
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html