use err/warn from C library
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 30 Apr 1993 04:21:32 +0000 (20:21 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 30 Apr 1993 04:21:32 +0000 (20:21 -0800)
SCCS-vsn: bin/pwd/pwd.c 5.6

usr/src/bin/pwd/pwd.c

index 6e561a0..93c659f 100644 (file)
@@ -12,15 +12,17 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)pwd.c      5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)pwd.c      5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
+
+#include <err.h>
 #include <errno.h>
 #include <stdio.h>
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <string.h>
+#include <unistd.h>
 
 void usage __P((void));
 
 
 void usage __P((void));
 
@@ -33,7 +35,7 @@ main(argc, argv)
        char *p;
 
        while ((ch = getopt(argc, argv, "")) != EOF)
        char *p;
 
        while ((ch = getopt(argc, argv, "")) != EOF)
-               switch(ch) {
+               switch (ch) {
                case '?':
                default:
                        usage();
                case '?':
                default:
                        usage();
@@ -44,13 +46,12 @@ main(argc, argv)
        if (argc != 0)
                usage();
 
        if (argc != 0)
                usage();
 
-       p = getcwd(NULL, 0);
-       if (p) {
-               (void)printf("%s\n", p);
-               exit(0);
+       if ((p = getcwd(NULL, 0)) == NULL) {
+               err(1, NULL);
+               exit(1);
        }
        }
-       (void)fprintf(stderr, "pwd: %s\n", strerror(errno));
-       exit(1);
+       (void)printf("%s\n", p);
+       exit(0);
 }
 
 void
 }
 
 void