(WRITTEN_BY): Rename from AUTHORS.
[platform/upstream/coreutils.git] / src / pwd.c
index 0f74d20..1c0a037 100644 (file)
--- a/src/pwd.c
+++ b/src/pwd.c
@@ -1,5 +1,5 @@
 /* pwd - print current directory
-   Copyright (C) 94, 95, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1994-1997, 1999-2003 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
 #include "system.h"
 #include "long-options.h"
 #include "error.h"
+#include "xgetcwd.h"
 
-char *xgetcwd ();
+/* The official name of this program (e.g., no `g' prefix).  */
+#define PROGRAM_NAME "pwd"
+
+#define WRITTEN_BY _("Written by Jim Meyering.")
 
 /* The name this program was run with. */
 char *program_name;
 
-static void
+void
 usage (int status)
 {
   if (status != 0)
@@ -39,13 +43,13 @@ usage (int status)
   else
     {
       printf (_("Usage: %s [OPTION]\n"), program_name);
-      printf (_("\
+      fputs (_("\
 Print the full filename of the current working directory.\n\
 \n\
-  --help      display this help and exit\n\
-  --version   output version information and exit\n\
-"));
-      puts (_("\nReport bugs to bug-sh-utils@gnu.ai.mit.edu"));
+"), stdout);
+      fputs (HELP_OPTION_DESCRIPTION, stdout);
+      fputs (VERSION_OPTION_DESCRIPTION, stdout);
+      printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
     }
   exit (status);
 }
@@ -55,20 +59,24 @@ main (int argc, char **argv)
 {
   char *wd;
 
+  initialize_main (&argc, &argv);
   program_name = argv[0];
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  parse_long_options (argc, argv, "pwd", GNU_PACKAGE, VERSION, usage);
+  atexit (close_stdout);
+
+  parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
+                     WRITTEN_BY, usage);
 
-  if (argc != 1)
+  if (1 < argc)
     error (0, 0, _("ignoring non-option arguments"));
 
   wd = xgetcwd ();
   if (wd == NULL)
-    error (1, errno, _("cannot get current directory"));
+    error (EXIT_FAILURE, errno, _("cannot get current directory"));
   printf ("%s\n", wd);
 
-  exit (0);
+  exit (EXIT_SUCCESS);
 }