~sircmpwn/ctools

ref: 10cfd2d3578789369ec35ab6635121f943635742 ctools/src/pwd.c -rw-r--r-- 489 bytes View raw
10cfd2d3Pedro L. Ramos Implemented pwd 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

static void
usage(void)
{
	fprintf(stderr, "usage: pwd [-L|-P]");
}

int
main(int argc, char *argv[])
{
	char *pwd = NULL;

	char opt;
	while ((opt = getopt(argc, argv, "LP")) != -1) {
		switch (opt) {
		case 'P':
			break;
		case 'L':
			break;
		default:
			usage();
			return 1;
		}
	}
	
	pwd = getcwd(pwd, 0);
	
	if (pwd == NULL) {
		return 1;
	}

	printf("%s\n", pwd);
	
	return 0;
}