1 /* pwd - print working directory Author: Norbert Schlenker */
4 * pwd - print working directory
7 * Author: Norbert Schlenker
8 * Copyright: None. Released to the public domain.
9 * Reference: IEEE P1003.2 Section 4.50 (draft 10)
10 * Bugs: No internationalization support; all messages are in English.
13 /* Force visible Posix names */
15 #define _POSIX_SOURCE 1
18 /* External interfaces */
19 #include <sys/types.h>
26 /* Magic numbers suggested or required by Posix specification */
27 #define SUCCESS 0 /* exit code in case of success */
28 #define FAILURE 1 /* or failure */
32 static char dir
[PATH_MAX
+ 1];
33 static char *errmsg
= "pwd: cannot search some directory on the path\n";
40 p
= getcwd(dir
, PATH_MAX
);
42 write(STDERR_FILENO
, errmsg
, strlen(errmsg
));
47 if (write(STDOUT_FILENO
, p
, n
+ 1) != n
+ 1) exit(FAILURE
);