1 /* `pwd.c` - return working directory name
2 Copyright (c) 2022, Alan Potteiger
3 See `LICENSE` for copyright and license details */
5 #define _POSIX_C_SOURCE 200809L
11 static const char *usage
= {
12 "usage: pwd [-L|-P]\n"
16 main(int argc
, char *argv
[])
26 while ((c
= getopt(argc
, argv
, "LP")) != -1) {
49 /* test pathname from $PWD for ./ or ../
50 if they exist, jump to the -P option */
52 for (; *p
!= '\0'; p
++) {
56 if (*(p
+1) == '.' && *(p
+1) == '/')