Browse Source

Fix -stripbase 1 output for d/ listing with multiple search specs

master
Julian Noble 10 months ago
parent
commit
6523b82583
  1. 23
      src/modules/punk-0.1.tm

23
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} {

Loading…
Cancel
Save