Questions about windows support
a at a.a
Sun Feb 26 14:10:35 PST 2012
"H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote in message
news:mailman.829.1329869699.20196.digitalmars-d at puremagic.com...
> On Tue, Feb 21, 2012 at 06:49:45PM -0500, Nick Sabalausky wrote:
>> I think that globbing should be done explicity by the app, *but* for
>> apps that don't play ball you should be able to *explicitly* do it at
>> the command line. Example:
>> $someutil *.txt foo.html
>> ERROR: Can't find file '*.txt'
>> $glob *.txt
>> 'hello.txt' 'Modern File Name.txt' 'another.txt'
>> $someutil `glob *.txt` foo.html
>> Processing hello.txt...done
>> Processing Modern File Name.txt...done
>> Processing another.txt...done
>> Processing foo.html...done
> Hmm. I like that idea: have the shell *not* interpolate things by
> default, unless you explicitly say to do so. So by default typing:
> rm *.txt
> will pass "*.txt" to rm as a single argument, whereas:
> # Not real syntax:
> rm `*.txt`
> will expand "*.txt" as a glob and pass the result to rm.
I've just thought of (ie, gotten bit by) another thing that would be nice
about having the commands do their own globbing:
If the applications glob on their own insted of the shell, then for safety
they can choose to restrict the number of file args they take to whatever
makes sense for their own individual purpose.
For example, suppose you want to delete everything inside a given
subdirectory (but keep the directory itself). So then you (mis)type:
$rm somedir/ * -rf
Note the subtle space before the "*". I just did that by mistake earlier
today, and the damage set me back a few hours (could have been much, much
worse, though). I don't think there's much, if anything, that can
realistically be done to protect against that right now. At least without
getting really hacky.
But, if rm was expected to do its own globbing instead of the shell doing
it, then rm could say: "Ok, it only makes sense for you to give me one
file/path at a time. Want more? Run me multiple times or use a glob pattern
(or hell, a regex pattern, or use a special explicit 'accept multiple paths'
mode, etc)." Then:
$rm somedir/ * -rf
ERROR: rm only takes one path at a time
$rm somedir/* -rf # ok
$rm somedir/ -rf # ok
$rm * -rf # ok
With the shell doing the expansion, that sort of thing isn't even possible.
Works with other stuff too:
$cp a b c
ERROR: You gave me a source path and a destination path, but then you gave
me *another* path! What the hell you expect *me* to do with it?
More information about the Digitalmars-d