From ed50b08a564ee5cad2b0e1ae0bfb777f06215410 Mon Sep 17 00:00:00 2001 From: aspect Date: Sun, 30 Apr 2017 05:34:44 +0000 Subject: glob for hidden files on unix should not require stat() --- tests/fileName.test | 19 +++++++++++++++++++ unix/tclUnixFile.c | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/fileName.test b/tests/fileName.test index d224011..4025b0f 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -730,6 +730,25 @@ test filename-11.12 {Tcl_GlobCmd} {testsetplatform} { set env(HOME) $home set x } {1 {couldn't find HOME environment variable to expand path}} +test filename-11.13 {Tcl_GlobCmd: hidden links on unix without stat()} -constraints {testsetplatform} -setup { + testsetplatform unix + file mkdir globTest/11.13 + close [open globTest/11.13/nonexistent w] + file link -symbolic globTest/11.13/badlink nonexistent + file link -symbolic globTest/11.13/.badlink nonexistent + file delete globTest/11.13/nonexistent +} -body { + # these should either both give results, or neither. Bug 391bc0fd2c + list [ + glob -nocomplain -tails -types l -dir globTest/11.13 * + ] [ + glob -nocomplain -tails -types {hidden l} -dir globTest/11.13/ * + ] +} -cleanup { + file delete globTest/11.13/badlink + file delete globTest/11.13/.badlink + file delete globTest/11.13 +} -result {badlink .badlink} if {[testConstraint testsetplatform]} { testsetplatform $platform diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index 0a2099c..a8bc9eb 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -433,7 +433,7 @@ NativeMatchType( return 0; } } else { - if (types->perm != 0) { + if ((types->perm & ~TCL_GLOB_PERM_HIDDEN) != 0) { if (TclOSstat(nativeEntry, &buf) != 0) { /* * Either the file has disappeared between the 'readdir' call @@ -474,7 +474,7 @@ NativeMatchType( } } if (types->type != 0) { - if (types->perm == 0) { + if ((types->perm & ~TCL_GLOB_PERM_HIDDEN) == 0) { /* * We haven't yet done a stat on the file. */ -- cgit v0.12