summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-03-28 06:17:34 +0000
committerJim Meyering <jim@meyering.net>1996-03-28 06:17:34 +0000
commitfee163dd572a1714ba93f582abe5e6683375c7e7 (patch)
tree0173deb87b45aac9c6d6ea7684dc363f11572822 /src
parentf954f7430226b5a36857f9a7e936d7d077cde111 (diff)
downloadcoreutils-fee163dd572a1714ba93f582abe5e6683375c7e7.tar.xz
Move usage to precede main.
Say `too few arguments' if that's why we display usage. Protoize. Include error.h. Update copyright.
Diffstat (limited to 'src')
-rw-r--r--src/chroot.c64
1 files changed, 29 insertions, 35 deletions
diff --git a/src/chroot.c b/src/chroot.c
index 31fa70fc3..549d87f71 100644
--- a/src/chroot.c
+++ b/src/chroot.c
@@ -12,36 +12,51 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <config.h>
#include <stdio.h>
#include "system.h"
#include "long-options.h"
-#include "version.h"
-
-void error ();
-
-static void usage ();
+#include "error.h"
/* The name this program was run with, for error messages. */
char *program_name;
-int
-main (argc, argv)
- int argc;
- char **argv;
+static void
+usage (int status)
{
- int c;
+ if (status != 0)
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+ else
+ {
+ printf ("Usage: %s [OPTION] NEWROOT [COMMAND...]\n", program_name);
+ printf ("\
+\n\
+ --help display this help and exit\n\
+ --version output version information and exit\n\
+\n\
+If no command is given, run ``${SHELL} -i'' (default: /bin/sh).\n\
+");
+ }
+ exit (status);
+}
+int
+main (int argc, char **argv)
+{
program_name = argv[0];
- parse_long_options (argc, argv, "chroot", version_string, usage);
+ parse_long_options (argc, argv, "chroot", PACKAGE_VERSION, usage);
if (argc == 1)
- usage (1);
+ {
+ error (0, 0, _("too few arguments"));
+ usage (1);
+ }
if (chroot (argv[1]))
error (1, errno, "cannot change root directory to %s", argv[1]);
@@ -66,24 +81,3 @@ main (argc, argv)
exit (1);
return 1;
}
-
-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] NEWROOT [COMMAND...]\n", program_name);
- printf ("\
-\n\
- --help display this help and exit\n\
- --version output version information and exit\n\
-\n\
-If no command is given, runs ``${SHELL} -i'' (default: /bin/sh).\n\
-");
- }
- exit (status);
-}