[comp.lang.perl] 'awk' test for file existance fails with nawk and gawk

djm@eng.umd.edu (David J. MacKenzie) (02/24/91)

In pl44 Configure does thus:

echo "First let's make sure your kit is complete.  Checking..."
(cd ..; awk '' `awk '$1 !~ /PACKINGLIST/ {print $1}' MANIFEST` >/dev/null || kill $$)
echo "Looks good..."

In other words, it relies on:
	awk '' files...
to exit with a nonzero status if not all of the files exist.
This seems to be what "old" awk does.
However, "new awk" (/bin/nawk on SunOs 4.1) prints nothing and exits
with status 0 in this case, and GNU awk prints a usage message.
Since these will be "awk" on many future systems (probably SVR4 and 4.4BSD),
I suggest changing the test to use some other method.
--
David J. MacKenzie <djm@eng.umd.edu> <djm@ai.mit.edu>

tytso@ATHENA.MIT.EDU (Theodore Ts'o) (02/26/91)

   From: djm@eng.umd.edu (David J. MacKenzie)
   Date: 24 Feb 91 05:34:52 GMT

   In other words, it relies on:
	   awk '' files...
   to exit with a nonzero status if not all of the files exist.
   This seems to be what "old" awk does.
   However, "new awk" (/bin/nawk on SunOs 4.1) prints nothing and exits
   with status 0 in this case, and GNU awk prints a usage message.

... and people keep claiming that awk is portable.  :-)

Well, you could use perl to test if all of the files are present.... no,
wait....  :-)

							- Ted

rbj@uunet.UU.NET (Root Boy Jim) (02/26/91)

In article <1991Feb25.172540.15875@uvaarpa.Virginia.EDU> tytso@ATHENA.MIT.EDU writes:
?
?   From: djm@eng.umd.edu (David J. MacKenzie)
?
?   In other words, it relies on:
?	   awk '' files...
?   to exit with a nonzero status if not all of the files exist.
?
?... and people keep claiming that awk is portable.  :-)
?
?Well, you could use perl to test if all of the files are present.... no,
?wait....  :-)

Or you could just forget it. It's a waste of time.

As Bo says: Just Do It. Get on with building the thing.
-- 
		[rbj@uunet 1] stty sane
		unknown mode: sane

lbr@holos0.uucp (Len Reed) (02/28/91)

In article <1991Feb25.172540.15875@uvaarpa.Virginia.EDU> tytso@ATHENA.MIT.EDU writes:
>
>Well, you could use perl to test if all of the files are present.... no,
>wait....  :-)

This seems to be an excellent idea.  You'd have to have an awk fall-back
mechanism, of course, but Configure is run far more often on machines
with [an earlier version of] perl already installed than on those
without any perl.  (Think patches.)  Even the oldest perls should
handle the rudimentary pattern matching needed for this task and give
consistent results, which is more than one can say for the various
flavors of awk.
-- 
Len Reed
Holos Software, Inc.
Voice: (404) 496-1358
UUCP: ...!gatech!holos0!lbr

pvo@sapphire.OCE.ORST.EDU (Paul O'Neill) (03/03/91)

In article <DJM.91Feb24003452@egypt.eng.umd.edu> djm@eng.umd.edu (David J. MacKenzie) writes:
>In pl44 Configure does thus:
>
>echo "First let's make sure your kit is complete.  Checking..."
>(cd ..; awk '' `awk '$1 !~ /PACKINGLIST/ {print $1}' MANIFEST` >/dev/null || kill $$)
>echo "Looks good..."
>

[WARNING, AS AN AWK ILLITERATE, I HAVE NO IDEA WHAT THIS IS ABOUT.
  I DID FIND THE SOLUTION, THOUGH!]

Then, of course, there's:

	Beginning of configuration questions for perl kit.
 
	First let's make sure your kit is complete.  Checking...
	awk: can't open MANIFEST
	[infinite freeze]

Solution: (This is on a NeXT 2.0 system)

	rmdir ../UU


Paul O'Neill--Coastal Imaging Lab	pvo@oce.orst.edu	DoD 000006 
OREGON STATE UNIVERSITY
OCEANOGRAPHY ADMIN BLDG 104
CORVALLIS OR 97331-5503			503-737-3251