From 8efa01a023d9168bb6cb8a1a4024b007e94e4114 Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Mon, 10 Dec 2018 11:39:50 +1100 Subject: * lib/utils.exp (getdirs): Use glob -nocomplain rather than glob and catching the "no files matched glob pattern" error message. Catching the error message was the wrong thing to do because the foreach loop then iterates over each word in the error message as if they were matches. --- lib/utils.exp | 53 ++++++++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'lib') diff --git a/lib/utils.exp b/lib/utils.exp index 57a6831..6acfa7c 100644 --- a/lib/utils.exp +++ b/lib/utils.exp @@ -44,44 +44,35 @@ proc getdirs { args } { set pattern "*" } verbose "Looking in $path for directories that match \"${pattern}\"" 3 - catch "glob $path/$pattern" tmp - if { $tmp ne "" } { - foreach i $tmp { - if {[file isdirectory $i]} { - switch -- "[file tail $i]" { - "testsuite" - - "config" - - "lib" - - ".git" - - ".svn" - - "CVS" - - "RCS" - - "SCCS" { - verbose "Ignoring directory [file tail $i]" 3 - continue - } - default { - if {[file readable $i]} { - verbose "Found directory [file tail $i]" 3 - lappend dirs $i - if { $alldirs } { - eval lappend dirs [getdirs -all $i $pattern] - } + set dirs [list] + foreach i [glob -nocomplain $path/$pattern] { + if {[file isdirectory $i]} { + switch -- "[file tail $i]" { + "testsuite" - + "config" - + "lib" - + ".git" - + ".svn" - + "CVS" - + "RCS" - + "SCCS" { + verbose "Ignoring directory [file tail $i]" 3 + continue + } + default { + if {[file readable $i]} { + verbose "Found directory [file tail $i]" 3 + lappend dirs $i + if { $alldirs } { + eval lappend dirs [getdirs -all $i $pattern] } } } } } - } else { - perror $tmp - return "" } - if {![info exists dirs]} { - return "" - } else { - return $dirs - } + return $dirs } -- cgit v1.1