aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-02-17 05:27:37 -0600
committerRob Landley <rob@landley.net>2012-02-17 05:27:37 -0600
commitb0f3037258e9c75d4109bb0e6754ab03d8750ddb (patch)
treeca059fe8bd085e9b03152b6bffaeda348c3287a8
parent60e817c6b0b60fa1864aea201baf95e252e87dde (diff)
downloadtoybox-b0f3037258e9c75d4109bb0e6754ab03d8750ddb.tar.gz
Move realpath from loopfiles() to a for loop, so we don't get hung on read permission for file data when we just want to look at directory info.
-rw-r--r--toys/realpath.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/toys/realpath.c b/toys/realpath.c
index 715fa872..10457cf6 100644
--- a/toys/realpath.c
+++ b/toys/realpath.c
@@ -12,20 +12,20 @@ config REALPATH
bool "realpath"
default y
help
+ usage: realpath FILE...
+
Display the canonical absolute pathname
*/
#include "toys.h"
-static void do_realpath(int fd, char *name)
-{
- if (!realpath(name, toybuf))
- perror_exit("realpath: cannot access %s'", name);
-
- xprintf("%s\n", toybuf);
-}
-
void realpath_main(void)
{
- loopfiles(toys.optargs, do_realpath);
+ char **s = toys.optargs;
+ for (s = toys.optargs; *s; s++) {
+ if (!realpath(*s, toybuf)) {
+ perror_msg("cannot access '%s'", *s);
+ toys.exitval = 1;
+ } else xputs(toybuf);
+ }
}