# HG changeset patch # User Rob Landley # Date 1329478057 21600 # Node ID 7d4dbde67dfb3a3a6b1c7ff6c49bb6d43eb0d031 # Parent 6378ca1da18e2307001664e2288a8e541a5d8ff0 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. diff -r 6378ca1da18e -r 7d4dbde67dfb toys/realpath.c --- a/toys/realpath.c Fri Feb 17 04:47:16 2012 -0600 +++ b/toys/realpath.c Fri Feb 17 05:27:37 2012 -0600 @@ -12,20 +12,20 @@ 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); + } }