On 12/16/2011 1:16 AM, Eric Smith wrote:
Josh Dersch wrote:
Wow, that's so elegant. It only requires
spawning two
processes, piping to a general purpose programming
language, and using regexps to make it work!
Bear in mind that a big part of the Unix philosophy is that rather
than providing tools that directly do anything you might need, Unix
(and associated software) are intended to give you simple tools that
you can combine, such that you can easily get more expressive power
than can be provided by a single complex tool. That includes
considering the shell as one of the tools. It isn't intended that the
shell alone do everything you might want; it is fully expected that
you will have tasks that require piping commands together.
Absolutely, I'm well aware of the Unix "many small tools" philosophy.
Whether that philosophy is appropriate for the average user, and
whether Unix and related software actually adhere to that philosophy
any more are debatable points. Whether the shell should have any easy
way to rename all the files *.foo to *.bar is an interesting
question. The fact that it is easy to do on DEC-like command parsers
doesn't imply that it's such a common operation that the shell should
offer it. I would actually argue the opposite; since Unix shells have
been around for many years without anyone being convinced that that
capability is necessary, it is clear that it is not a common operation
for most people, and that it's OK to have to combine a few tools to do
it.
I don't agree with this general position (that because Unix doesn't have
it, it's obvious that no one wants the behavior), actually (in general
-- not necessarily in this specific case) but it's mostly a matter of
opinion and I don't think we need yet another rathole on this mailing
list about it :).
I -will- add that due to Unix's shell design (namely the decision that
the shell expands wildcards on behalf of the tools it executes) that it
does make it impossible (at least in a consistent manner) to enable some
operations that I think *would* be useful in the general case.
For a basic example, if "rm" could know it was passed "*" as an
argument
it could (if not disabled with another flag of course) protect the user
from purging his/her home directory with a friendly
("hey, you sure
about this?") prompt? (I know, I know -- Unix being
friendly, what am I
thinking, restrain yourselves.)
I know there are other ad hoc ways to solve the above problem, but the
issue with the ad hoc methods is that they aren't consistent from one
machine to another so you can't rely on them being present.
I realize this goes against another, unwritten, Unix philosophy: "Unix
makes it easy to screw yourself to the wall, and that's a good thing
because I'm l33t." Remember that the next time you type "rm * .o"
instead of "rm *.o" by mistake. :)
(Yes I know Unix gurus never make typos, it's purely hypothetical.)
- Josh