commit 15524157755d0d1452624d1e66659dba2bf6a7c3
parent 3616be790d722e6037bd436c654d9a2c0c48a7e7
Author: tjg <tjg>
Date: Thu, 25 Jul 2002 12:19:17 +0000
Bug: fix globbing of broken symlinks.
Diffstat:
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -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
@@ -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
diff --git a/glob.c b/glob.c
@@ -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);
diff --git a/trip.rc b/trip.rc
@@ -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