file function and directory separator troubles...
- From: Gerhard Reithofer <gerhard.reithofer@xxxxxxxxxxxxxx>
- Date: Sun, 18 Nov 2007 02:36:40 +0100
As I'm currently porting many scripts from unix to windows and writing
new ones for both platforms I've found some troubles using the file
split/join function.
The reason is, that [file join] always uses the forward slash as
directory separator. So you always have to distinguish if the resulting
path name is used within tcl (which makes no troubles) or if the results
are used by the "system" windows.
I found at least 3 situations where the file function cannot be used
to manage file paths unreflectingly:
1. when creating files which will be executed by the system. An
example is writing a batch file using path names in commands, eg.:
% puts $batchfile "@echo off\n[file join $basedir $module startup.exe]"
2. when using file join with environment variables for path names, eg.:
% if {$env(EXE_NAME) eq [file join $basedir $module startup.exe]} ...
3. when using joined path names in exec (or pipes). E.g. the command
% exec acrobat [file join $docdir $module help.pdf]
fails with acrobat reader 8.
I've found that the last problem is in general a acrobat reader
behaviour, but if the [file join] would use "native" directory
separators, the problem would not occur.
All these cases require a special handling on the generated path names,
which makes the platform independency of these functions inoperatively.
Some questions:
1. Does anyone have a solution for this (except doing regsub -all ...
on each path name)?
2. Should this behaviour become changed in general. IMHO I do not see
any reason to keep this behaviour for "compatibility" reasons?
3. Would that be worth to write a TIP to add an option to the
file subcommands to use the "native" separators.
I'm afraid it would be too late for 8.5?
--
Gerhard Reithofer
Tech-EDV Support Forum - http://support.tech-edv.co.at
.
- Follow-Ups:
- Re: file function and directory separator troubles...
- From: tom.rmadilo
- Re: file function and directory separator troubles...
- From: Fredderic
- Re: file function and directory separator troubles...
- From: Gerry Snyder
- Re: file function and directory separator troubles...
- Prev by Date: Looking for a Tcl wrapper for libusb-win32
- Next by Date: strange behaviour.
- Previous by thread: Looking for a Tcl wrapper for libusb-win32
- Next by thread: Re: file function and directory separator troubles...
- Index(es):
Relevant Pages
|