Path: utzoo!utgpu!watmath!clyde!att!rutgers!ucsd!sdcsvax!ucsdhub!hp-sdd!ncr-sd!ncrlnk!uunet!mcvax!ukc!stc!idec!marlow!fox
From: fox@marlow.uucp (Paul Fox)
Newsgroups: comp.unix.wizards
Subject: Testing for non-empty wildcards
Message-ID: <502@alice.marlow.uucp>
Date: 3 Dec 88 19:27:21 GMT
Organization: Reuters Ltd PLC, Marlow, England
Lines: 50

Hello wide world...yet another boring shell question.

Given that in the C-shell you can do things like:

	if ( -e ...long..file..spec ) ...

is there a way to test whether a sub-directory contains any
wild-carded files. What I mean is, I have a subdirectory 'sccs'
in each of my development directories. I have a shell script 'sccs'
in /usr/local/bin which does some nice but useful things with the
sccs commands. I can do something like:

	sccs update

which translates into:

	foreach i (sccs/p.*)
		set file = something_horrible
		delta sccs/s.$file
		get sccs/s.$file
	end

The problem I have is that if there are no sccs/p.* files, then
cshell complains that there is a wildcard mismatch.

My current hack is the following:

                set nonomatch
                set a = sccs/p.*
                if ( "$a" == "sccs/p.*" ) exit 0

which relies on the fact that if nonomatch is set, then '*' evaluates
to '*' if the wildcard fails. I think this is horrible, and may have
nasty side effects.

How does one do this properly in the C-shell & Bourne Shell.
(I am not particularly interested in the K-sh since I need portability.
Yes I know C-shell is not available on all systems, but it is 
available on more systems that K-sh).

Many thanks


=====================
     //        o      All opinions are my own.
   (O)        ( )     The powers that be ...
  /    \_____( )
 o  \         |
    /\____\__/        Tel: +44 628 891313 x. 212
  _/_/   _/_/         UUCP:     fox@marlow.uucp