diff options
Diffstat (limited to 'coreutils/readlink.c')
-rw-r--r-- | coreutils/readlink.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/coreutils/readlink.c b/coreutils/readlink.c index 0a9aa95..e17fc3b 100644 --- a/coreutils/readlink.c +++ b/coreutils/readlink.c @@ -68,12 +68,11 @@ int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int readlink_main(int argc UNUSED_PARAM, char **argv) { char *buf; - char *fname; unsigned opt; + /* -n must use bit 0 (see printf below) */ opt = getopt32(argv, "^" "n" IF_FEATURE_READLINK_FOLLOW("fvsq") "\0" "=1"); - fname = argv[optind]; /* compat: coreutils readlink reports errors silently via exit code */ if (!(opt & 4)) /* not -v */ @@ -81,14 +80,14 @@ int readlink_main(int argc UNUSED_PARAM, char **argv) /* NOFORK: only one alloc is allowed; must free */ if (opt & 2) { /* -f */ - buf = xmalloc_realpath_coreutils(fname); + buf = xmalloc_realpath_coreutils(argv[optind]); } else { - buf = xmalloc_readlink_or_warn(fname); + buf = xmalloc_readlink_or_warn(argv[optind]); } if (!buf) return EXIT_FAILURE; - printf((opt & 1) ? "%s" : "%s\n", buf); + printf("%s%s", buf, &"\n"[opt & 1]); free(buf); fflush_stdout_and_exit_SUCCESS(); |