1 /* vi: set sw=4 ts=4: */
3 * Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
5 * Now does proper error checking on output and returns a failure exit code
6 * if one or more paths cannot be resolved.
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 //config:config REALPATH
11 //config: bool "realpath (2.5 kb)"
14 //config: Return the canonicalized absolute pathname.
15 //config: This isn't provided by GNU shellutils, but where else does it belong.
17 //applet:IF_REALPATH(APPLET_NOFORK(realpath, realpath, BB_DIR_USR_BIN, BB_SUID_DROP, realpath))
19 //kbuild:lib-$(CONFIG_REALPATH) += realpath.o
21 /* BB_AUDIT SUSv3 N/A -- Apparently a busybox extension. */
23 //usage:#define realpath_trivial_usage
25 //usage:#define realpath_full_usage "\n\n"
26 //usage: "Print absolute pathnames of FILEs"
30 int realpath_main(int argc
, char **argv
) MAIN_EXTERNALLY_VISIBLE
;
31 int realpath_main(int argc UNUSED_PARAM
, char **argv
)
33 int retval
= EXIT_SUCCESS
;
40 /* NOFORK: only one alloc is allowed; must free */
41 char *resolved_path
= xmalloc_realpath_coreutils(*argv
);
42 if (resolved_path
!= NULL
) {
46 retval
= EXIT_FAILURE
;
47 bb_simple_perror_msg(*argv
);
51 fflush_stdout_and_exit(retval
);