1 /* vi: set sw=4 ts=4: */
3 * Mini readlink implementation for busybox
5 * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
7 * Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
14 int readlink_main(int argc, char **argv);
15 int readlink_main(int argc, char **argv)
20 USE_FEATURE_READLINK_FOLLOW(
22 /* We need exactly one non-option argument. */
23 opt_complementary = "=1";
24 opt = getopt32(argv, "f");
27 SKIP_FEATURE_READLINK_FOLLOW(
28 const unsigned opt = 0;
29 if (argc != 2) bb_show_usage();
33 /* compat: coreutils readlink reports errors silently via exit code */
34 logmode = LOGMODE_NONE;
37 buf = realpath(fname, bb_common_bufsiz1);
39 buf = xmalloc_readlink_or_warn(fname);
46 if (ENABLE_FEATURE_CLEAN_UP && !opt)
49 fflush_stdout_and_exit(EXIT_SUCCESS);