diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-22 00:47:18 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-22 00:47:18 +0200 |
commit | fbb12ddc6a53ad97ff6bcc7ed9b253c09001ad2f (patch) | |
tree | 94c82f9eac30c86a1ec4f4d06f6c17b72b47cf3e /coreutils | |
parent | b6bca7703bbe6aacec0bda964c82fad389a02b69 (diff) | |
download | busybox-w32-1_14_2.tar.gz busybox-w32-1_14_2.tar.bz2 busybox-w32-1_14_2.zip |
post 1.14.1 fixes; bump version to 1.14.21_14_2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/readlink.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/coreutils/readlink.c b/coreutils/readlink.c index 721fd8597..bcf352e74 100644 --- a/coreutils/readlink.c +++ b/coreutils/readlink.c | |||
@@ -6,9 +6,31 @@ | |||
6 | * | 6 | * |
7 | * Licensed under GPL v2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPL v2 or later, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | |||
10 | #include "libbb.h" | 9 | #include "libbb.h" |
11 | 10 | ||
11 | /* | ||
12 | * # readlink --version | ||
13 | * readlink (GNU coreutils) 6.10 | ||
14 | * # readlink --help | ||
15 | * -f, --canonicalize | ||
16 | * canonicalize by following every symlink in | ||
17 | * every component of the given name recursively; | ||
18 | * all but the last component must exist | ||
19 | * -e, --canonicalize-existing | ||
20 | * canonicalize by following every symlink in | ||
21 | * every component of the given name recursively, | ||
22 | * all components must exist | ||
23 | * -m, --canonicalize-missing | ||
24 | * canonicalize by following every symlink in | ||
25 | * every component of the given name recursively, | ||
26 | * without requirements on components existence | ||
27 | * -n, --no-newline do not output the trailing newline | ||
28 | * -q, --quiet, -s, --silent suppress most error messages | ||
29 | * -v, --verbose report error messages | ||
30 | * | ||
31 | * bbox supports: -f -n -v (fully), -q -s (accepts but ignores) | ||
32 | */ | ||
33 | |||
12 | int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 34 | int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
13 | int readlink_main(int argc UNUSED_PARAM, char **argv) | 35 | int readlink_main(int argc UNUSED_PARAM, char **argv) |
14 | { | 36 | { |
@@ -20,7 +42,7 @@ int readlink_main(int argc UNUSED_PARAM, char **argv) | |||
20 | unsigned opt; | 42 | unsigned opt; |
21 | /* We need exactly one non-option argument. */ | 43 | /* We need exactly one non-option argument. */ |
22 | opt_complementary = "=1"; | 44 | opt_complementary = "=1"; |
23 | opt = getopt32(argv, "f"); | 45 | opt = getopt32(argv, "fnvsq"); |
24 | fname = argv[optind]; | 46 | fname = argv[optind]; |
25 | ) | 47 | ) |
26 | SKIP_FEATURE_READLINK_FOLLOW( | 48 | SKIP_FEATURE_READLINK_FOLLOW( |
@@ -30,9 +52,10 @@ int readlink_main(int argc UNUSED_PARAM, char **argv) | |||
30 | ) | 52 | ) |
31 | 53 | ||
32 | /* compat: coreutils readlink reports errors silently via exit code */ | 54 | /* compat: coreutils readlink reports errors silently via exit code */ |
33 | logmode = LOGMODE_NONE; | 55 | if (!(opt & 4)) /* not -v */ |
56 | logmode = LOGMODE_NONE; | ||
34 | 57 | ||
35 | if (opt) { | 58 | if (opt & 1) { /* -f */ |
36 | buf = realpath(fname, pathbuf); | 59 | buf = realpath(fname, pathbuf); |
37 | } else { | 60 | } else { |
38 | buf = xmalloc_readlink_or_warn(fname); | 61 | buf = xmalloc_readlink_or_warn(fname); |
@@ -40,7 +63,7 @@ int readlink_main(int argc UNUSED_PARAM, char **argv) | |||
40 | 63 | ||
41 | if (!buf) | 64 | if (!buf) |
42 | return EXIT_FAILURE; | 65 | return EXIT_FAILURE; |
43 | puts(buf); | 66 | printf((opt & 2) ? "%s" : "%s\n", buf); |
44 | 67 | ||
45 | if (ENABLE_FEATURE_CLEAN_UP && !opt) | 68 | if (ENABLE_FEATURE_CLEAN_UP && !opt) |
46 | free(buf); | 69 | free(buf); |