2020-12-12 06:33:20 +00:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
|
2020-02-12 05:30:50 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
|
|
int mode = 01; /* 01: print PWD -L, 02: print physical path -P */
|
2020-12-13 16:22:44 +00:00
|
|
|
char c;
|
2020-02-12 05:30:50 +00:00
|
|
|
|
2020-12-13 16:22:44 +00:00
|
|
|
while((c = getopt(argc, argv, "LP")) != -1) {
|
|
|
|
switch(c) {
|
|
|
|
case 'L': mode = 01; break;
|
|
|
|
case 'P': mode = 02; break;
|
2020-02-12 05:30:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mode == 01) {
|
|
|
|
printf("%s\n", getenv("PWD"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("%s\n", getcwd(NULL, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|