Linked by Eugenia Loli on Mon 20th Mar 2006 07:13 UTC
General Unix After receiving several comments to his November 2005 article on hating UNIX, David Chisnall offers his responses and further insight on his continuing disdain.
Thread beginning with comment 105963
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[4]: Shell Globing
by Sheld on Mon 20th Mar 2006 15:08 UTC in reply to "RE[3]: Shell Globing"
Sheld
Member since:
2005-12-21

Because "mv *.foo *.bar" would introduce a discrepancy with the way file globing usualy works. '*.bar' doesn't stand for anything in your example, you might as well drop the *.

I think introducing this kind of odd behaviour makes the shell less user friendly, not more user friendly. The for loop might be more verbose but at least it's clear, comprehensible and coherent with the rest of the system. As I said 'remame *.foo .foo .bat' for example is not much longer than 'mv *.foo *.bat' and compliant with the Unix semantic, it's a much better solution.

As for your new command, I suppose you meant "mv qux_foo_*_.{cpp,h} qux_bar_*_.{cpp,h}", it looks more and more as if your mv command is going to have to read in the user's mind, using regular expressions would be much more natural and less error prone (what if the two file globings don't match?). "rename qux_foo_*_.{cpp,h} s/qux_foo/qux_bar/", or today:

for f in qux_foo_*_.{cpp,h}; do mv $f $(sed 's/qux_foo/qux_bar/' <<< $f); done

You're trying to fix a problem which doesn't exist.

Reply Parent Score: 1

RE[5]: Shell Globing
by Vanders on Mon 20th Mar 2006 16:07 in reply to "RE[4]: Shell Globing"
Vanders Member since:
2005-07-06

To be fair, I'm not trying to fix anything. If I personally really felt that file globing was a big problem, Syllable wouldn't be using bash and I'd have written a different shell that doesn't do automatic globing. There are generally workarounds to most problems; you've provided plenty of examples of scripts that can do mv operations on complex filesets.

What bothers me is the argument "That's the way UNIX has always done it so it can't ever be wrong". Globing is mearly a simple example of this.

P.S: O.K, so "mv *.foo *.bar" isn't syntactically correct if you're running a Bourne-like shell. Nor does "mv *.foo .bar" make much sense and .bar could be a directory anyway. Your suggestion of having a special purpose "rename" command isn't right either; now you have two commands "mv" to move files and "rename" to rename them and the user needs to know what the difference is.

Perhaps my real beef is that the Bourne shell syntax is not expressive enough. Or perhaps it's the fact that traditionally, UNIX commands are non-interactive so can not gracefully handle ambigious cases. Perhaps the problem only exists in my head and everything is just peachy. Although I'd rather be talking about these sorts of things than taking the absolute position that UNIX is the evolutionary be-all and end-all of Operating System design.

Reply Parent Score: 3

RE[6]: Shell Globing
by Ookaze on Mon 20th Mar 2006 17:40 in reply to "RE[5]: Shell Globing"
Ookaze Member since:
2005-11-14

There are generally workarounds to most problems

There start the misunderstanding : these are not workarounds, these are the correct way to deal with the problem, AKA one of the solutions.

What bothers me is the argument "That's the way UNIX has always done it so it can't ever be wrong". Globing is mearly a simple example of this

And there lies another misunderstanding. The argument is not that at all, the argument is "UNIX has been thought out but people keep coming, that without having studied anything about Unix and its command line, come with solutions full of design problems, worse than what we have now".
Saying globing is wrong, when it lays on years of studies of automata design and logic, that you learn in CS courses, is amazing to me. Especially since globing works so well.
At least, the author of the original troll seems to know Unix.

P.S: O.K, so "mv *.foo *.bar" isn't syntactically correct if you're running a Bourne-like shell

Wrong again, it's syntactically correct, it just is not gramatically correct (with the mv command) if .bar is not a directory. Then the shell won't complain, mv will.

Nor does "mv *.foo .bar" make much sense and .bar could be a directory anyway

Again, it makes sense, and will work as long as .bar is a directory.

Your suggestion of having a special purpose "rename" command isn't right either; now you have two commands "mv" to move files and "rename" to rename them and the user needs to know what the difference is

Knowing your tool. That's what I talked about earlier. Man is there for a reason.
Like I said earlier too, the problem here is not the tool, it's a bad understanding of regular expression : a beginner's classic mistake.

Perhaps my real beef is that the Bourne shell syntax is not expressive enough. Or perhaps it's the fact that traditionally, UNIX commands are non-interactive so can not gracefully handle ambigious cases

What do you mean ? Of course they can. You're starting a course on automata or what ? That's precisely the kind of things that automata try to solve, and you can write one in shell if you want (I would not advise you to do that though).

Reply Parent Score: 1

RE[7]: Shell Globing
by Vanders on Mon 20th Mar 2006 19:42 in reply to "RE[5]: Shell Globing"
Vanders Member since:
2005-07-06

Wow. You've managed to reply to my post without ever reading it. You havn't even the slightest understanding of the small out-of context parts of my post that you've quoted. NIce work.

Heres the executive summary for you:

1) I never said globbing was bad.
2) I never said "mv *.foo *.bar" was wrong as it is currently implemented
3) I never said "mv *.foo .bar" was wrong either.
4) It boggles my mind that anyone could think having two tools that do only slightly different things could be a good idea.
5) UNIX tools are not traditionally interactive.
6) You've completly flown off the handle and entirely missed the point of the article, the arguments raised within, my reply and no doubt, this reply as well.

Well done. You qualify for your UNIX beard and certificate of "Approaching Computing as a Purely Academic Excercise".

Reply Parent Score: 2

RE[6]: Shell Globing
by Sheld on Mon 20th Mar 2006 19:54 in reply to "RE[5]: Shell Globing"
Sheld Member since:
2005-12-21

It's not so much that it's "the way it has always been" as it is that there is a good reason for things to be the way they are, and if you don't fully understand how file globing works and why it is the way it is, then you may think that something is wrong with it.

If something was wrong with the way it works and if some other way had clear advantages it would have been fixed a long time ago, the Unix world is not that conservative.

Reply Parent Score: 1