/* basename -- strip directory and suffix from filenames
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* date - print or set the system date and time
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* dirname -- strip filename suffix from pathname
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* echo.c, taken from Bash.
-Copyright (C) 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
+ Copyright (C) 87, 89, 91, 92, 93, 1994 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* env - run a program in a modified environment
- Copyright (C) 1986, 1991 Free Software Foundation, Inc.
+ Copyright (C) 86, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* id -- print real and effective UIDs and GIDs
- Copyright (C) 1989, 1991 Free Software Foundation.
+ Copyright (C) 89, 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* logname -- print user's login name
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* nice -- run a program with modified scheduling priority
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* pathchk -- check whether pathnames are valid or portable
- Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Copyright (C) 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* printenv -- print all or part of environment
- Copyright (C) 1989, 1991 Free Software Foundation.
+ Copyright (C) 89, 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
David MacKenzie and Richard Mlynarik */
+#ifdef HAVE_CONFIG_H
+#if defined (CONFIG_BROKETS)
+/* We use <config.h> instead of "config.h" so that a compilation
+ using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+ (which it would do because it found this file in $srcdir). */
+#include <config.h>
+#else
+#include "config.h"
+#endif
+#endif
+
#include <stdio.h>
#include <sys/types.h>
+#include <getopt.h>
+
+#include "version.h"
#include "system.h"
+void error ();
+
+/* The name this program was run with. */
+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[] =
+{
+ {"help", no_argument, &show_help, 1},
+ {"version", no_argument, &show_version, 1},
+ {0, 0, 0, 0}
+};
+
extern char **environ;
+static void
+usage (status)
+ int status;
+{
+ if (status != 0)
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+ else
+ {
+ printf ("Usage: %s [OPTION]... [VARIABLE]...\n", program_name);
+ printf ("\
+\n\
+ --help display this help and exit\n\
+ --version output version information and exit\n\
+\n\
+If no VARIABLE, print them all.\n\
+");
+ }
+ exit (status);
+}
+
void
main (argc, argv)
int argc;
char *ep, *ap;
int i;
int matches = 0;
+ int c;
+ int exit_status;
+
+ program_name = argv[0];
- if (argc == 1)
+ while ((c = getopt_long (argc, argv, "", long_options, (int *) 0)) != EOF)
{
- for (env = environ; *env; ++env)
- puts (*env);
+ switch (c)
+ {
+ case 0:
+ break;
+
+ default:
+ usage (1);
+ }
+ }
+
+ if (show_version)
+ {
+ printf ("%s\n", version_string);
exit (0);
}
- for (i = 1; i < argc; ++i)
+ if (show_help)
+ usage (0);
+
+ if (optind == argc)
+ {
+ for (env = environ; *env != NULL; ++env)
+ puts (*env);
+ exit_status = 0;
+ }
+ else
{
- for (env = environ; *env; ++env)
+ for (i = optind; i < argc; ++i)
{
- ep = *env;
- ap = argv[i];
- while (*ep != '\0' && *ap != '\0' && *ep++ == *ap++)
- if (*ep == '=' && *ap == '\0')
- {
- puts (ep + 1);
- ++matches;
- break;
- }
+ for (env = environ; *env; ++env)
+ {
+ ep = *env;
+ ap = argv[i];
+ while (*ep != '\0' && *ap != '\0' && *ep++ == *ap++)
+ {
+ if (*ep == '=' && *ap == '\0')
+ {
+ puts (ep + 1);
+ ++matches;
+ break;
+ }
+ }
+ }
}
+ exit_status = (matches != argc - optind);
}
- exit (matches != argc - 1);
+
+ if (ferror (stdout) || fclose (stdout) == EOF)
+ error (2, errno, "standard output");
+
+ exit (exit_status);
}
/* printf - format and print data
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* sleep - delay for a specified amount of time.
Copyright (C) 1984, 1991 Free Software Foundation, Inc.
+ Copyright (C) 84, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* stty -- change and print terminal line settings
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* su for GNU. Run a shell with substitute user and group IDs.
- Copyright (C) 1992 Free Software Foundation, Inc.
+ Copyright (C) 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* tee - read from standard input and write to standard output and files.
- Copyright (C) 1985, 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 85, 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Modified to run with the GNU shell by bfox. */
-/* Copyright (C) 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1987-1993, 1994 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* tty -- print the path of the terminal connected to standard input
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* uname -- print system information
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* GNU's who.
- Copyright (C) 1992 Free Software Foundation, Inc.
+ Copyright (C) 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* whoami -- print effective userid
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Equivalent to `id -un'. */
/* Written by Richard Mlynarik. */
+#ifdef HAVE_CONFIG_H
+#if defined (CONFIG_BROKETS)
+/* We use <config.h> instead of "config.h" so that a compilation
+ using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+ (which it would do because it found this file in $srcdir). */
+#include <config.h>
+#else
+#include "config.h"
+#endif
+#endif
+
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
+#include <getopt.h>
+
+#include "version.h"
#include "system.h"
+/* The name this program was run with. */
+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[] =
+{
+ {"help", no_argument, &show_help, 1},
+ {"version", no_argument, &show_version, 1},
+ {0, 0, 0, 0}
+};
+
+static void
+usage (status)
+ int status;
+{
+ if (status != 0)
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+ else
+ {
+ printf ("Usage: %s [OPTION]...\n", program_name);
+ printf ("\
+\n\
+ --help display this help and exit\n\
+ --version output version information and exit\n\
+\n\
+Same as id -un.\n\
+");
+ }
+ exit (status);
+}
+
void
main (argc, argv)
int argc;
{
register struct passwd *pw;
register uid_t uid;
+ int c;
+
+ program_name = argv[0];
+
+ while ((c = getopt_long (argc, argv, "", long_options, (int *) 0)) != EOF)
+ {
+ switch (c)
+ {
+ case 0:
+ break;
+
+ default:
+ usage (1);
+ }
+ }
- if (argc != 1)
+ if (show_version)
{
- fprintf (stderr, "Usage: %s\n", argv[0]);
- exit (1);
+ printf ("%s\n", version_string);
+ exit (0);
}
+ if (show_help)
+ usage (0);
+
+
+ if (optind != argc)
+ usage (1);
+
uid = geteuid ();
pw = getpwuid (uid);
if (pw)
puts (pw->pw_name);
exit (0);
}
- fprintf (stderr,"%s: cannot find username for UID %u\n", argv[0], uid);
+ fprintf (stderr, "%s: cannot find username for UID %u\n",
+ program_name, (unsigned) uid);
exit (1);
}
/* yes - output a string repeatedly until killed
- Copyright (C) 1991 Free Software Foundation, Inc.
+ Copyright (C) 91, 92, 93, 1994 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* David MacKenzie <djm@ai.mit.edu> */
+/* David MacKenzie <djm@gnu.ai.mit.edu> */
+
+#ifdef HAVE_CONFIG_H
+#if defined (CONFIG_BROKETS)
+/* We use <config.h> instead of "config.h" so that a compilation
+ using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+ (which it would do because it found this file in $srcdir). */
+#include <config.h>
+#else
+#include "config.h"
+#endif
+#endif
#include <stdio.h>
+#include <getopt.h>
+
+#include "version.h"
+#include "long-options.h"
+
+/* The name this program was run with. */
+char *program_name;
+
+static void
+usage (status)
+ int status;
+{
+ if (status != 0)
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+ else
+ {
+ printf ("Usage: %s [OPTION]... [STRING]...\n", program_name);
+ printf ("\
+\n\
+ --help display this help and exit\n\
+ --version output version information and exit\n\
+\n\
+Without any STRING, assume `y'.\n\
+");
+ }
+ exit (status);
+}
void
main (argc, argv)
int argc;
char **argv;
{
- int i;
+ program_name = argv[0];
+
+ parse_long_options (argc, argv, usage);
if (argc == 1)
while (1)
puts ("y");
while (1)
- for (i = 1; i < argc; i++)
- {
- fputs (argv[i], stdout);
- putchar (i == argc - 1 ? '\n' : ' ');
- }
+ {
+ int i;
+
+ for (i = 1; i < argc; i++)
+ {
+ fputs (argv[i], stdout);
+ putchar (i == argc - 1 ? '\n' : ' ');
+ }
+ }
}