Re: Beware wildcards in Kill
From: Russ Holsclaw (russ_at_holsclaw.nyet)
Date: 04/08/04
- Next message: Russ Holsclaw: "Re: Split command"
- Previous message: Peter Huang: "RE: SHELLing out to a shortcut"
- In reply to: Tony Proctor: "Beware wildcards in Kill"
- Next in thread: Tony Proctor: "Re: Beware wildcards in Kill"
- Reply: Tony Proctor: "Re: Beware wildcards in Kill"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 8 Apr 2004 09:10:17 -0600
> It is a long-standing issue that wildcards in a DOS
context (e.g. DIR.EXE)
> do not behave in a reliable manner. For instance '*'
should be 0-or-more
> characters, and '?' should be any single character.
However, if you type the
> following in a DOS command window:
>
> DEL xyz????.dat
>
> then it will delete xyz.dat as well as xyz1234.dat.
>
> You could argue that in this context '?' is handled as
0-or-1 characters,
> but this is out-of-step with the rest of the World
including Windows - just
> try a Search in an Explorer window to see the difference.
>
> However, what is less obvious is that the VB Kill
statement has the same
> totally useless, and very dangerous, semantics.
This behavior is only "illogical" in the context of viewing
the filename as a variable-length character string.
You're overlooking the fact that every file in the Windows
file system has two names: the original DOS-compatible
fixed-length "8.3" name and the variable-length "long" name.
To maintain compatibility between the "old" and "new"
worlds, Windows allows operations against any file by
referencing either name.
The old 8.3 name is stored in the directory in a fixed
11-character data structure, with two separate "fields",
with 8 "filename" characters and 3 "extension" characters.
The period between them is not actually there, and each
portion is stored in a fixed-length field, padded by space
characters [chr$(32), as it were]. The "?" wildcards match
ANY character, including space. The file xyz.dat is stored
in DOS form as XYZ^^^^^DAT (where ^ represents a space, in
this case).
This behavior matches that of the original DOS system, which
was, in turn, designed to match the behavior of the CP/M
file system upon which it was loosely based.
What you're seeing is not truly "illogical" you see, it's
merely the "ghost" of downward compatibility. Like it or
not, that's something that happens to every operating
system, sooner or later.
In light of this, it might have been better if the Windows
file system had allowed a program to specify specifically
whether a filename reference is to the "old-style" name or
the "new-style" one. Unfortunately, as applied to this
particular case, they didn't. On the other hand, it could be
argued that it would have needlessly complicated programming
interfaces, and it usually doesn't create undesirable
results. But... sometimes it does, if you're too fixated
only on the rules of "new-style" filenames, and ignore the
old-style ones lurking in the background.
- Next message: Russ Holsclaw: "Re: Split command"
- Previous message: Peter Huang: "RE: SHELLing out to a shortcut"
- In reply to: Tony Proctor: "Beware wildcards in Kill"
- Next in thread: Tony Proctor: "Re: Beware wildcards in Kill"
- Reply: Tony Proctor: "Re: Beware wildcards in Kill"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|