forked from pyenv/pyenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
realpath.c
43 lines (38 loc) · 832 Bytes
/
realpath.c
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
41
42
43
#include "bash.h"
#include <stdlib.h>
#include <stdio.h>
int realpath_builtin(list)
WORD_LIST *list;
{
int es;
char *realbuf, *p;
if (list == 0) {
// builtin_usage();
return (EX_USAGE);
}
for (es = EXECUTION_SUCCESS; list; list = list->next) {
p = list->word->word;
realbuf = realpath(p, NULL);
if (realbuf == NULL) {
es = EXECUTION_FAILURE;
// builtin_error("%s: cannot resolve: %s", p, strerror(errno));
} else {
printf("%s\n", realbuf);
free(realbuf);
}
}
return es;
}
char *realpath_doc[] = {
"Display each PATHNAME argument, resolving symbolic links. The exit status",
"is 0 if each PATHNAME was resolved; non-zero otherwise.",
(char *)NULL
};
struct builtin realpath_struct = {
"realpath",
realpath_builtin,
BUILTIN_ENABLED,
realpath_doc,
"realpath pathname [pathname...]",
0
};