Mercurial > hg > toybox
changeset 470:7d4dbde67dfb
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.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 17 Feb 2012 05:27:37 -0600 |
parents | 6378ca1da18e |
children | 35f6a1bd1417 |
files | toys/realpath.c |
diffstat | 1 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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); + } }