diff options
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/realpath.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/coreutils/realpath.c b/coreutils/realpath.c index 7ef935ee0..f89e0a274 100644 --- a/coreutils/realpath.c +++ b/coreutils/realpath.c | |||
| @@ -21,24 +21,22 @@ | |||
| 21 | 21 | ||
| 22 | int realpath_main(int argc, char **argv) | 22 | int realpath_main(int argc, char **argv) |
| 23 | { | 23 | { |
| 24 | char *resolved_path; | 24 | RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX); |
| 25 | int count; | ||
| 26 | 25 | ||
| 27 | if (argc == 1) { | 26 | if (--argc == 0) { |
| 28 | show_usage(); | 27 | show_usage(); |
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | resolved_path = malloc(PATH_MAX); | 30 | do { |
| 32 | 31 | argv++; | |
| 33 | for (count = 1; count < argc; count++) { | 32 | if (realpath(*argv, resolved_path) != NULL) { |
| 34 | resolved_path = realpath(argv[count], resolved_path); | ||
| 35 | if (resolved_path) { | ||
| 36 | puts(resolved_path); | 33 | puts(resolved_path); |
| 37 | } else { | 34 | } else { |
| 38 | perror_msg("%s", argv[count]); | 35 | perror_msg("%s", *argv); |
| 39 | } | 36 | } |
| 40 | } | 37 | } while (--argc); |
| 41 | free(resolved_path); | 38 | |
| 39 | RELEASE_CONFIG_BUFFER(resolved_path); | ||
| 42 | 40 | ||
| 43 | return(EXIT_SUCCESS); | 41 | return(EXIT_SUCCESS); |
| 44 | } \ No newline at end of file | 42 | } |
