On Dec 16, 2011, at 1:55 PM, Mouse wrote:
For a basic
example, if "rm" could know it was passed "*" as an
argument it could [] protect the user [...]
I think it's no coincidence that most Lisp systems provide a way to
write not only functions that eval their arguments, but `functions'
that get passed their arguments unevaled.
Some of the reasons for this have no analog here. But some are fairly
closely analogous.
If we could invent some way for a program to indicate, pre-exec, that
it wants unglobbed (`unevaled') arguments, this might be doable.
You can; I certainly have to pass that to "find" often enough. Just encase your
argument in quotes, e.g.:
find . -name "*.tar.gz"
That's actually how I discovered that the shell was expanding the arguments rather
than the program.
Of course, that doesn't "fix" programs that aren't expecting to expand
wildcards, because they'll just try to operate on a file called "*.tar.gz"
(which is a valid filename; if I do a 'touch "*.foo"', a file called
"*.foo" exists in my directory). And it doesn't change the default behavior
of programs if the arguments are passed unprotected.
(Yes I know
Unix gurus never make typos, it's purely hypothetical.)
Har. Anyone who thinks Unix gurus never make typos is clearly not a
Unix guru.
That's why Unix commands are mostly two characters; it's either to minimize the
possibility of a typo, or maximize the fun when you make one (for example, when I'm
off by one, "fg" becomes "df", which is fairly innocuous, but one
could feasibly accidentally do an "rm" or something by mistake).
- Dave