From b0f3037258e9c75d4109bb0e6754ab03d8750ddb Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 17 Feb 2012 05:27:37 -0600 Subject: [PATCH] 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. --- toys/realpath.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/toys/realpath.c b/toys/realpath.c index 715fa87..10457cf 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); + } } -- 2.7.4