Deutsch   English   Français   Italiano  
<100cd5q$unbu$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: saito <saitology9@gmail.com>
Newsgroups: comp.lang.tcl
Subject: Re: Problems with paths of Windows
Date: Sun, 18 May 2025 06:35:38 -0400
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <100cd5q$unbu$1@dont-email.me>
References: <100ae16$fom5$1@dont-email.me> <100aepq$frvv$1@dont-email.me>
 <ba04ce42-d26a-4adf-a9ac-45b5d5266e5e@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 18 May 2025 12:35:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2f7ee05210964b319e6dc17bede4b4d7";
	logging-data="1006974"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX198peWD0l56sjETOkWZUMKF"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:zAFeZ14x5rp+4tj7QS7Uqe8kXFE=
Content-Language: en-US
In-Reply-To: <ba04ce42-d26a-4adf-a9ac-45b5d5266e5e@yahoo.com>

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.