26 lines
474 B
C
Executable file
26 lines
474 B
C
Executable file
#define _POSIX_C_SOURCE 200809L
|
|
|
|
#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 */
|
|
char c;
|
|
|
|
while((c = getopt(argc, argv, "LP")) != -1) {
|
|
switch(c) {
|
|
case 'L': mode = 01; break;
|
|
case 'P': mode = 02; break;
|
|
}
|
|
}
|
|
|
|
if(mode == 01) {
|
|
printf("%s\n", getenv("PWD"));
|
|
}
|
|
else {
|
|
printf("%s\n", getcwd(NULL, 0));
|
|
}
|
|
|
|
return 0;
|
|
}
|