diff options
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | glob.c | 6 | ||||
| -rw-r--r-- | trip.rc | 8 |
4 files changed, 16 insertions, 4 deletions
@@ -788,3 +788,7 @@ Changes since rc-1.5b2 2002-06-18 Release: rc-1.7. + +2002-07-25 + + Bug: fix globbing of broken symlinks. diff --git a/configure.ac b/configure.ac index ffe9357..6dddecc 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,7 @@ AC_TYPE_SIZE_T AC_TYPE_UID_T AC_CHECK_TYPE(ssize_t, long) -AC_CHECK_FUNCS(getgroups setpgrp setrlimit) +AC_CHECK_FUNCS(getgroups lstat setpgrp setrlimit) RC_FUNC_GETGROUPS RC_FUNC_SIGSETJMP @@ -1,7 +1,7 @@ /* glob.c: rc's (ugly) globber. This code is not elegant, but it works */ #include "rc.h" -#include <sys/stat.h> +#include "stat.h" /* Lifted from autoconf documentation.*/ #if HAVE_DIRENT_H @@ -86,7 +86,7 @@ extern List *glob(List *s) { /* Matches a pattern p against the contents of directory d */ static List *dmatch(char *d, char *p, char *m) { - bool matched = FALSE; + bool matched; List *top, *r; static DIR *dirp; static struct dirent *dp; @@ -107,7 +107,7 @@ static List *dmatch(char *d, char *p, char *m) { if (matched) { char *path = nprint("%s/%s", d, p); - if (stat(path, &s) < 0) + if (lstat(path, &s) < 0) return NULL; r = nnew(List); r->w = ncpy(p); @@ -587,6 +587,14 @@ fn x {echo x.y $(x.y)} ~ ``''{whatis -f x} 'fn x {echo x.y $''x.y''} ' || fail sneaky parens bug +# before rc-1.7.1, certain glob patterns could fail on broken symlinks +mkdir $tmp.qux +ln -s /frobnatz $tmp.qux/foo +x=$tmp.qux/foo* +~ $x $tmp.qux/foo || { rm -rf $tmp.qux; fail broken symlink globbing } +x=$tmp.qux*/foo +~ $x $tmp.qux/foo || { rm -rf $tmp.qux; fail broken symlink globbing } + # large file support # this is, by no means, an exhaustive test. since particular file |