Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-02-27
23:11 • Ticket [1438236fff] UNIX vs DOS Slashes status still Closed with 4 other cha... artifact: ed2a9b0499 user: speedboat
22:38 • Ticket [1438236fff]: 2 changes artifact: afed316f92 user: dgp
22:38 • Closed ticket [1438236fff]. artifact: 4bad70019e user: dgp
21:00 • Ticket [1438236fff]: 4 changes artifact: 4af1e41d52 user: speedboat
21:00 • Ticket [1438236fff]: 4 changes artifact: cdf61b1368 user: speedboat
2006-02-25
12:03 • Ticket [1438236fff]: 4 changes artifact: a60be07123 user: dgp
00:43 • Ticket [1438236fff]: 4 changes artifact: 9cb659cd53 user: speedboat
2006-02-24
17:38 • New ticket [1438236fff]. artifact: 5b842051d7 user: nobody

UNIX vs DOS Slashes

Closed / Rejected1438236fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2006-02-24 17:38:22
In the Windows runtime environment, most environment 
variables are defined with what I'll call dos-like 
slashes "\". But the TCLLIBPATH environment variable 
is actually used inside the init.tcl script, and 
requires unix-like slashes "/".

Would it be possible to add this one line:

if { [string equal $tcl_platform
(platform) "windows"] } { set env(TCLLIBPATH) [string 
map {\\ \/} $env(TCLLIBPATH)] }

And Change ($TCL_ROOT/lib/init.tcl):

if {![info exists auto_path]} {
    if {[info exists env(TCLLIBPATH)]} {
set auto_path $env(TCLLIBPATH)
    } else {
set auto_path ""
    }
}


To:

if {![info exists auto_path]} {
    if {[info exists env(TCLLIBPATH)]} {
if { [string equal $tcl_platform
(platform) "windows"] } { set env(TCLLIBPATH) [string 
map {\\ \/} $env(TCLLIBPATH)] }
set auto_path $env(TCLLIBPATH)
    } else {
set auto_path ""
    }
}

The will allow "package requires" to succeed no 
matter how and where the TCLLIBPATH was defined.

FYI. My TCLLIBPATH is set within a .bat script and 
I'm finding it painfully difficult to reverse the 
direction of the slashes.
speedboatplain2006-02-25 00:43:07
Logged In: YES 
user_id=243036

Sorry, did not mean to submit as "nobody".

If you think it's a silly idea, I'll still claim it. ;)

Al
dgpplain2006-02-25 12:03:21
Logged In: YES 
user_id=80530


Please give an example of a
value of TCLLIBPATH that this
would help.  I suspect any such
example would simply be an
invalid value of TCLLIBPATH, which
must be a Tcl list.

If there's a valid use case, I think
a pass with [file normalize] ought
to take care of things.
speedboatplain2006-02-27 21:00:01
Logged In: YES 
user_id=243036

I have a .bat script which determines it's own location, 
for example C:\MyDir. The .bat script then sets the 
TCLLIBPATH accordingly, for example: 

    set TCLLIBPATH=%MYDIR%/path/to/my/packages %
MYDIR%/another/path

Which results in:

   C:\MyDir/path/to/my/packages C:\MyDir/another/path

which will not work.

[file normalize] would be great, I didn't realize it would 
work on a list of file paths, but it would still need to 
be include in init.tcl probably as:

   set auto_path [file normalize $env(TCLLIBPATH)]

I agree the .bat script is providing tcl an illegal list 
of directory paths, but it's far easier to correct within 
tcl than it is in the batch script. It's also a fairly 
easy problem to generate when most of the other 
environment variables (Ex. TCL_ROOT, TCL_LIBRARY) in 
the .bat script require DOS-like slashes.
speedboatplain2006-02-27 21:00:17
Logged In: YES 
user_id=243036

I have a .bat script which determines it's own location, 
for example C:\MyDir. The .bat script then sets the 
TCLLIBPATH accordingly, for example: 

    set TCLLIBPATH=%MYDIR%/path/to/my/packages %
MYDIR%/another/path

Which results in:

   C:\MyDir/path/to/my/packages C:\MyDir/another/path

which will not work.

[file normalize] would be great, I didn't realize it would 
work on a list of file paths, but it would still need to 
be include in init.tcl probably as:

   set auto_path [file normalize $env(TCLLIBPATH)]

I agree the .bat script is providing tcl an illegal list 
of directory paths, but it's far easier to correct within 
tcl than it is in the batch script. It's also a fairly 
easy problem to generate when most of the other 
environment variables (Ex. TCL_ROOT, TCL_LIBRARY) in 
the .bat script require DOS-like slashes.
dgpplain2006-02-27 22:38:07
Logged In: YES 
user_id=80530


If you are going to put a literal 
backslash character in the value
of TCLLIBPATH, you will need to
enclose the list element containing
that character with braces.  Try:

set TCLLIBPATH={%MYDIR%/path/to/my/packages}
{%MYDIR%/another/path}

Contrary to your claim, this is not easier
to correct within Tcl than outside, because
the "correction" you are asking for, is really
to make a "guess" as to what the input "means".
Somehow you want Tcl to guess when the backslashes
are supposed to be literal, and when they are supposed
to have Tcl's normal substitution rules.

This kind of Do What I Mean interface always
eventually leads to trouble when a different
context makes the guesses wrong.

Follow the rules and Say What You Mean.
dgp Ticket [1438236fff]: 2 changes [History diff]2006-02-27 22:38:08
speedboatplain2006-02-27 23:11:46
Logged In: YES 
user_id=243036

And I thought I tried every combination of quotes and 
braces. Sorry, guess not.

Thanks, I withdraw my request. It's of course much better 
to fix the problem at the source, I just couldn't figure 
out how.
Log in (anonymous is fine) to add a comment.