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 105921
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE: Shell Globing
by Vanders on Mon 20th Mar 2006 10:29 UTC in reply to "Shell Globing"
Vanders
Member since:
2005-07-06

Not really. The problem with globing being in the shell is that application never get a chance to pre-process their command line arguments before the shell expands them. At least if the globing were somewhere both the shell and the application could access it and control it's behavour, commands such as "mv *.foo *.bar" would actually have a chance of working.

Edited 2006-03-20 10:30

Reply Parent Score: 2

RE[2]: Shell Globing
by Ronald Vos on Mon 20th Mar 2006 11:08 in reply to "RE: Shell Globing"
Ronald Vos Member since:
2005-07-06

At least if the globing were somewhere both the shell and the application could access it and control it's behavour, commands such as "mv *.foo *.bar" would actually have a chance of working.

And to think people were heftily discussing the expressiveness of the commandline only yesterday ;)

Reply Parent Score: 1

RE[2]: Shell Globing
by Sheld on Mon 20th Mar 2006 14:06 in reply to "RE: Shell Globing"
Sheld Member since:
2005-12-21

What's wrong with "for f in *.foo; do mv $f $(basename $f .foo).bar; done"?

"mv *.foo *.bar" doesn't make much sense, something like "rename *.foo .foo .bar" would seem more logical.

And of course file globing is available from the glibc, so writing a rename command which would correctly handle "rename '*.foo' .bar" is very easy. Such a command is just too specific to become part of the standard Unix toolbox.

Reply Parent Score: 5

RE[3]: Shell Globing
by Vanders on Mon 20th Mar 2006 14:37 in reply to "RE[2]: Shell Globing"
Vanders Member since:
2005-07-06

It was mearly a simple example. What's wrong with your equivilent loop is that it is far more verbose and less obvious. Why write a for loop when the shell could do it for me? What if I wanted to do "mv qux*_foo_*_.[cpp|h] qux_bar_*_.[cpp|h]"? Write, test and debug an even bigger shell script?

Just because the UNIX shell doesn't allow me to write "mv *.foo *.bar" doesn't mean it's a bad idea. Why should there be an artificial barrier to writing applications to do more useful things?

Reply Parent Score: 1

RE[3]: Shell Globing
by SomeGuy on Mon 20th Mar 2006 17:21 in reply to "RE[2]: Shell Globing"
SomeGuy Member since:
2006-03-20

You mean like the "rename" command, shipped with my system? Quoting from the man page:
NAME
rename - Rename files

SYNOPSIS
rename from to file...
DESCRIPTION
rename will rename the specified files by replacing the first occurrence of from in their name by to.

Reply Parent Score: 1

RE[3]: Shell Globing
by bogomipz on Mon 20th Mar 2006 17:31 in reply to "RE[2]: Shell Globing"
bogomipz Member since:
2005-07-11

Yeah, and such a command does actually exist. It's syntax is (from `man rename`):

rename .htm .html *.htm

Reply Parent Score: 1