ls

News system owner ID news at bbn.COM
Sat Oct 14 06:45:17 AEST 1989


In article <21100 at adm.BRL.MIL> bush%ecs.oxford.ac.uk at nsfnet-relay.ac.uk (Mark Bush) writes:
< grep 'pattern' .[^.]* *
< 
< will probably match `.'!

If the shell is _correctly_ handling the [^LETTERS] regexp (which Sys
V shell thinks is [!LETTERS], but grep knows the truth), then
neither . nor .. will be matched.  Remeber: [ABC] means match one of
'A', 'B', or 'C'.  This is _non-optional_; there must be a letter there.

< .[\ -,\/-~]*
< 
< does work in bash but seems to want to include both `.' and `..' in csh!!!!
< Of course this pattern precludes files starting `.-' as well but who cares?

Neat; a bug.  Tcsh gets this wrong too, in case anyone is wondering;
I'll have to fix that.  It _should_ work in everything.  I think it's
caused by a quoting-bit (8th bit inside csh -- don't ask) problem,
with the \/ (backquoted forward-quote).

Try this:

	capella quant_test 332 -> echo 'foo is bar' > '.-'
	capella quant_test 333 -> echo .[\ --/-~]*
	.-
	capella quant_test 334 -> 

Note that you don't have to quote the second -; it's only magic when
_between_ letters.

< The inconsistancies here are more far reaching that it seems at first.
< Perhaps shells should be written so that `.*' precludes `.' and `..'?

Nope; not at all.  Ever.  If the user can't get the regexp right,
that's not the fault of the shell, and the shell shouldn't be made to
work _wrong_.

		-- Paul Placeway <now PPlaceway at bbn.com>



More information about the Comp.unix.wizards mailing list