[comp.unix.misc] Globbing

peter@ficc.ferranti.com (Peter da Silva) (02/27/91)

In article <KERS.91Feb26095613@cdollin.hpl.hp.com> kers@hplb.hpl.hp.com (Chris Dollin) writes:
> Somebody writes glob_the_lot and makes it available. Assorted people make
> trivial changes to code. End of story. The difficulty resides in making sure
> that the changes happen consistently on given platforms.

Plus how you figure out where quotes have been stripped off by shells, the
original c runtime startup, and so on.
-- 
Peter da Silva.  `-_-'  peter@ferranti.com
+1 713 274 5180.  'U`  "Have you hugged your wolf today?"

fetter@cos.com (Bob Fetter) (02/28/91)

In article <KERS.91Feb26095613@cdollin.hpl.hp.com> kers@hplb.hpl.hp.com (Chris Dollin) writes:
>
>"Turning off globbing would make existing programs harder to (re)write?" (said
>at least once). Bloody hell.
>
>extern int glob_the_lot
>    ( int argc, char **argv, void mainly( int argc, char **argv ) );
>
>int main( int argc, char *argv )
>    {
>    return glob_the_lot( argc, argv, original_main );
>    }
>
>Somebody writes glob_the_lot and makes it available. Assorted people make
>trivial changes to code. End of story. The difficulty resides in making sure
>that the changes happen consistently on given platforms.

  You forget that the entire reason for putting this into the executables
is *not* to offload mindless globbing from the shell, but to put in some
sense of -semantics- into the globbing process.

 What one might expect from executable globbing is that there would be
a understanding of the context in which the globbing is to take place.

  I can imagine a command:

	read_mail *.net_mbx -only_from *.RMT-HOST -subject *glob*

which could (in my imagination) read mailboxes, performing a globbing
operation on all '*.net_mbx' mailboxes, passing arguments which select
mail items from users on a system named 'RMT-HOST' (assuming RFC-822-esk
structure) and wanting only those messages which have the string 'glob'
somewhere in the subject line.

  Nuke city with a shell globber.

  Now, this is only in my imagination on Unix.  Elsewhere, now, it's a
different story.  Whether this is a 'good thing' in today's Unix world
is yet another question.

  -Bob-

mju@mudos.ann-arbor.mi.us (Marc Unangst) (03/11/91)

fetter@cos.com (Bob Fetter) writes:
> different story.  Whether this is a 'good thing' in today's Unix world
> is yet another question.

If you need to be convinced that taking globbing out of the shell is a
Bad Thing, just look at MS-DOS.  MS-DOS has never done wildcard
globbing for you, and as a result, you have about sixteen thousand
different wildcard expansion schemes out there.  Some programs don't
even support wildcards.  Some do, but don't support things like
"*/file" (i.e., a wildcarded directory name).  Some make you type
"*.*" if you mean "all files", and some accept "*" for "all files".
(Programs of the former type usually take "*" to mean "all files
without an extension".)

But definitely the best are the programs that follow COMMAND.COM's
lead in expanding wildcards -- "*word*" is the same as "*", which
means if you type "del *foo*.bar", you will REALLY delete "*.bar".

It's a pain in the ass to remember which programs use which globbing
schemes.  And it can cause actual damage, if you can't remember what
globbing scheme a program uses and do something like the
aforementioned "del *foo*.bar".  I'd *much* prefer that the shell do
the globbing -- at least then, you have some sort of consistancy.

--
Marc Unangst               |
mju@mudos.ann-arbor.mi.us  | "Bus error: passengers dumped"
...!umich!leebai!mudos!mju | 

john@sco.COM (John R. MacMillan) (03/11/91)

|  I can imagine a command:
|
|	read_mail *.net_mbx -only_from *.RMT-HOST -subject *glob*
|
| [...]
|
|  Nuke city with a shell globber.

read_mail \*.net_mbx -only_from \*.RMT-HOST -subject '*glob*'

If you don't want globbing in your shell, turn it off.  If you want
your programs to do globbing, or more complex regexps, do it.  If
people with globbing shells then have to quote things, big deal.

dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) (03/12/91)

In <DmNmy1w164w@mudos.ann-arbor.mi.us> mju@mudos.ann-arbor.mi.us (Marc
Unangst) writes:

>If you need to be convinced that taking globbing out of the shell is a
>Bad Thing, just look at MS-DOS.  MS-DOS has never done wildcard
>globbing for you, and as a result, you have about sixteen thousand
>different wildcard expansion schemes out there.

Actually the whole truth is that (a) MS-DOS provides a somewhat flaky
system call that does do globbing for you, but that (b) it is rather
inconvenient to use this system call, and it has bugs to preserve
compatibility with CP/M, whose corresponding system call also had
bugs.

So the reason that programmers invent their own globbing schemes under
MS-DOS is not because the MS-DOS shell doesn't do it, but because the
system call provided does it so badly.  If the system call did a better
job, programmers would use it, because it would be more convenient than
rolling their own.
--
Rahul Dhesi <dhesi%cirrusl@oliveb.ATC.olivetti.com>
UUCP:  oliveb!cirrusl!dhesi