Re: file command bug on windows



At Sun, 05 Apr 2009 20:31:28 +0200 =?windows-1252?Q?=D3scar_Fuentes?= <ofv@xxxxxxxxxx> wrote:


Mark Janssen <mpc.janssen@xxxxxxxxx> writes:

% file type ~123
user "123" doesn't exist
% file type ~456
user "456" doesn't exist
% cd ~456
user "456" doesn't exist
This has not to do with the file command, but with Tcl's file name
resolution of ~ (as evident from the cd error). If filenames starting
with ~ are allowed in your application, you can sanitize them with
code like this:
% regsub {^~} ~456~78 ./&
./~456~78

Thanks for the solution. That will work...
But I was just wanted to know if "file", "cd", etc. should have been
written
to ignore interpreting  "~dir" as a user's home directory.

No, why would you want to do that -- each user has a valid home directory.

BTW, on most other file systems you can also put a tilde in a file name.
Just like on windows it is very very very rarely put at the beginning of a
file name (one of the common *inx editors, Emacs, puts it at the end of a
file name to indicate a backup file).

Yes, I agree that every user has a valid home directory. But on
Windows the user's home
directories are not referred to with a leading tilde symbol. That
convention is used
only on Unix'es and maybe other OS's. So I was just wondering if the
relevant commands
should ignore this convention on Windows. Not that its a major problem
though, with
Suchenwi's solution.

The fact that ~something is interpreted as a home directory is working
as documented and is useful in windows as well as in Unix.

Well, it may be documented, it may be useful, but it is broken. A
leading tilde is just another symbol on Windows, and it is not different
from an 'A'. If tcl treats it on a specific way, Tcl is broken.

You should realize that tilde is also 'just another symbol' on UNIX as
well. It is just that *tradionally* it is a shorthand (in sh, csh,
bash, etc.) for a users home directory as well, and this shorthand usage
is also used in tclsh/wish, as well as other. The 'trick' of
preceding a leading tilde with a directory spec (eg "./") to suppress
the home directory substitution works for UNIX as well. Under UNIX
"./~foo" is a ligit filename and is a filename that starts with the
literal character '~'. A bit awkward do deal with from a command
shell, but not any worse than a filename starting with a dash.


[snip]


--
Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller@xxxxxxxxxxxx -- Contract Programming: C/C++, Tcl/Tk


.



Relevant Pages

  • Re: file command bug on windows
    ... as documented and is useful in windows as well as in Unix. ... The manual page for `filename` on Tcl 8.4.13 says this: ... The Macintosh and Windows platforms do not support tilde substitution ...
    (comp.lang.tcl)
  • Re: file command bug on windows
    ... If tcl treats it on a specific way, ... You should realize that tilde is also 'just another symbol' on UNIX as ... Windows is not Unix. ...
    (comp.lang.tcl)
  • A cross platform question
    ... On Unix, we can usually obtain a user's home directory through ... By if the same script is to run on Windows, ...
    (comp.lang.tcl)
  • Re: What is a shortcut to the Default home directory in Windows
    ... I need it to be in there home directory in WINDOWS. ... That works on both unix and windows. ... environment variables %HOMEDRIVE% and %HOMEPATH%. ...
    (comp.lang.python)
  • Re: Saving to subfolders
    ... the same folder hierarchy in Mac OS X as there is in Windows. ... It's the the way Unix does things. ... anywhere within your home directory (including folders you've created ...
    (comp.sys.mac.system)