Sujet : Re: Problems with paths of Windows
De : saitology9 (at) *nospam* gmail.com (saito)
Groupes : comp.lang.tclDate : 18. May 2025, 11:35:38
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <100cd5q$unbu$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 5/17/2025 10:36 PM, Luis Alejandro Muzzachiodi wrote:
given the following procedure
proc myproc { listofpaths } {
foreach p $listofpaths {
puts "$p - is valid? : [file isdirectory $p]"
}
}
if a parameter is passed as "$::env(SystemRoot)\my dir"
the result obtained is
C:Windowsmy - is valid? : 0
dir - is valid? : 0
You know, the problem here is something else completely: your proc is expecting a list of file names. Instead it gets a string containing a single file name. So what happens is that the foreach loop takes that string, splits it into a list at each space character, and processes each part separately. So "$::env(SystemRoot)\my dir" turns into "$::env(SystemRoot)\my" and "dir" as you see in your output. You don't want this implicit conversion.
Instead, turn your input into a proper list before calling your proc above and all should be good.