1 /* vi: set sw=4 ts=4: */
2 /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
4 * Now does proper error checking on output and returns a failure exit code
5 * if one or more paths cannot be resolved.
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 //config:config REALPATH
10 //config: bool "realpath (1.1 kb)"
13 //config: Return the canonicalized absolute pathname.
14 //config: This isn't provided by GNU shellutils, but where else does it belong.
16 //applet:IF_REALPATH(APPLET(realpath, BB_DIR_USR_BIN, BB_SUID_DROP))
18 //kbuild:lib-$(CONFIG_REALPATH) += realpath.o
20 /* BB_AUDIT SUSv3 N/A -- Apparently a busybox extension. */
22 //usage:#define realpath_trivial_usage
24 //usage:#define realpath_full_usage "\n\n"
25 //usage: "Return the absolute pathnames of given FILE"
29 int realpath_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
30 int realpath_main(int argc UNUSED_PARAM, char **argv)
32 int retval = EXIT_SUCCESS;
39 char *resolved_path = xmalloc_realpath(*argv);
40 if (resolved_path != NULL) {
44 retval = EXIT_FAILURE;
45 bb_simple_perror_msg(*argv);
49 fflush_stdout_and_exit(retval);