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.
16 int readlink_main(int argc, char **argv)
21 USE_FEATURE_READLINK_FOLLOW(
23 /* We need exactly one non-option argument. */
24 opt_complementary = "=1";
25 opt = getopt32(argc, argv, "f");
28 SKIP_FEATURE_READLINK_FOLLOW(
29 const unsigned opt = 0;
30 if (argc != 2) bb_show_usage();
34 /* compat: coreutils readlink reports errors silently via exit code */
35 logmode = LOGMODE_NONE;
38 buf = realpath(fname, bb_common_bufsiz1);
40 buf = xreadlink(fname);
47 if (ENABLE_FEATURE_CLEAN_UP && buf != bb_common_bufsiz1)
50 fflush_stdout_and_exit(EXIT_SUCCESS);