diff --git a/src/modules/punk-0.1.tm b/src/modules/punk-0.1.tm index 22ee0d53..5cf5f1b5 100644 --- a/src/modules/punk-0.1.tm +++ b/src/modules/punk-0.1.tm @@ -5866,24 +5866,37 @@ namespace eval punk { #we have already done a 'cd' if only one unglobbed path was supplied - therefore any remaining non-glob tails must be tested for folderness vs fileness to see what they mean #this may be slightly surprising if user tries to exactly match both a directory name and a file in that the dir will be listed - but is consistent enough. #lower level dirfiles or dirfiles_dict can be used to more precisely craft searches. ( d/ will treat dir the same as dir/*) + + set searchspec_relative [expr {[file pathtype $searchspec] eq "relative"}] if {$has_tailglob} { set location [file dirname $path] set glob [file tail $path] + if {$searchspec_relative} { + set searchbase [pwd] + } else { + set searchbase [file dirname $searchspec] + } } else { if {[file isdirectory $path]} { set location $path set glob * + if {$searchspec_relative} { + set searchbase [pwd] + } else { + set searchbase $path + } } else { set location [file dirname $path] set glob [file tail $path] ;#search for exact match file + if {$searchspec_relative} { + set searchbase [pwd] + } else { + set searchbase [file dirname $path] + } } } + set matchinfo [punk::dirfiles_dict -searchbase $searchbase -tailglob $glob $location] - if {[file pathtype $searchspec] eq "absolute"} { - set matchinfo [punk::dirfiles_dict -searchbase "" -tailglob $glob $location] - } else { - set matchinfo [punk::dirfiles_dict -searchbase [pwd] -tailglob $glob $location] - } set location [file normalize [dict get $matchinfo location]] if {$location ne $last_location} {