[mod.unix] Unix Technical Digest V2 #8

netnews@wnuxb.UUCP (Heiby) (06/05/85)

Unix Technical Digest       Wed,  5 Jun 85       Volume  2 : Issue   8

Today's Topics:
                        ARPA time in SYS III?
                       Problems with make & sh
                 Unix source include file conventions
           USENIX and IEEE P1003 "UNIX Standards" committee
----------------------------------------------------------------------

Date: Thu, 30 May 85 19:39:45 CST
From: Stan Barber <rice!neuro1!sob>
Subject: ARPA time in SYS III?

I have been having problems getting the timezone from SYS III without
having a TZ environmental variable, and ftime seems a bit inscruitable
for some reason (my brain may be the problem). Can some one offer an
explination or sample code for the best way to pull an arpa-format time
from the system without the shell or its environment to help?

------------------------------

Date: Thu, 30 May 85 17:09:47 edt
From: allegra!phri!roy (Roy Smith)
Subject: Problems with make & sh

Keywords: make, sh -e, 4.2bsd, automatic dependency generators (ADCs)

	I'm trying to make make an ADC for a library.  The idea is to
have a list of source modules, grep each module for 'include' lines and
then run the grep output through sed and awk to put it in the right
format.  Thus the following 'makefile' fragment (line numbers added in
press):

1	for module in ${MODULES}; \
2	do \
3		echo seqlib.a:: "$$module.o;" ar r seqlib.a $$module.o; \
4		grep '^# *include' $$module.c | \
5		sed -e "s![^<]*<\([^>]*\)>.*!$$module.o: ${INCLUDE}/\1!" \
6		    -e "s![^\"]*\"\([^\"]*\)\".*!$$module.o: \1!" | \
7		awk '{if ($$1 != prev) {print rec; rec = $$0; prev = $$1;} \
8		      else {if (length(rec $$2) > 78) {print rec; rec = $$0;} \
9			    else rec = rec " " $$2}} \
10		      END {print rec}' ; \
11	done >> Makefile.new

	The problem is with modules that don't have any includes; grep
exits with status 1 which causes make to die.  I tried such subterfuges
as "if grep ...; then true; else true;" and "grep ... || true" and
various versions of these with ()'s to execute them in sub-shells, all to
no avail.

	Eventually, I figured out that when make exec's a shell, it uses
the "-e" flag which says to exit immediately if any command returns
non-zero status.  It seems that there is no way to turn this flag off
once it is turned on [talk about write-only memories :-)].  Since "echo
$-" prints the flags, you would think "-=''" would clear them.  All that
does is get a syntax error.  Ugh!

	I have figured out 2 work-arounds.

	The first would be to write a one-line shell which just does the
"grep ..." and call that from the shell file.  Fortunately explicitly
called sub-shells don't inherit the -e flag (as the sub-shells generated
by putting a command in parens seem to).  This seems ugly and confusing,
so I'd rather not resort to it.

	The second would be to stick a "-" in front of the "for" on line
1, but that turns off more error checking than I want.

	Any suggestions?

allegra!phri!roy (Roy Smith)
System Administrator, Public Health Research Institute

[Ed note: I think I'd use:  sh -c "grep .......;true"	RWH.]

------------------------------

Date: Sun, 2 Jun 85 16:52:49 pdt
From: dual!decwrl!powell (Michael L. Powell)
Subject: Unix source include file conventions

I've seen lots of messages over the years about the pains of include files in
the Unix system source:  Problems occur when you include them multiple times or
in the wrong order; you never know what include file needs what other ones; the
files are in different directories in different systems; and variables get
defined too many or too few times.  Various fixes have been suggested that seem
reasonable to me, but I wonder why they haven't been implemented by the
purveyors of Unix software.

The idea is to make each xyz.h file look like this (minus the comments):

#ifndef INCL_XYZ

#include <abc.h>	/* list all files needed by this file, i.e., so that */
...
#include <pqr.h>	/* a file with just #include <xyz.h> will compile */

#ifdef DEFINE_XYZ
#define EXTERN		/* don't put extern in front of vars */
#else
#define EXTERN extern	/* put extern in front of vars */
#endif

/* normal definitions for .h are the same as always */
/* but variable declarations look like this: */
EXTERN int nmbclusters;

#define INCL_XYZ	/* only scan this file once */
#endif

This convention permits you to include only those files that you want.  The
other ones will show up as necessary.  A file that wishes to define the
variables listed in an include file simply defines DEFINE_XYZ before the
includes.

I am also mystified by the use of #include "../h/xyz.h" instead of <xyz.h>.
The latter seems more consistent and allows the makefile or compilation command
to specify where to look for include files.
-- 
Michael L. Powell, Digital Equipment Corporation
Western Research Laboratory, Los Altos, CA  94022
{decvax,ucbvax}!decwrl!powell

------------------------------

Date: Thu, 30 May 85 13:34:50 cdt
From: ihnp4!ut-sally!jsq%im4u.ARPA (John Quarterman)
Subject: USENIX and IEEE P1003 "UNIX Standards" committee

The USENIX board has asked me to act as the representative of USENIX
to the IEEE P1003 "UNIX Standards" committee.  My function is to
communicate the position of the USENIX membership and board to the
committee, and to inform USENIX about what the committee is doing.
I will also vote for USENIX, where it is appropriate for USENIX
to have a vote.  In such cases I will vote the position of USENIX,
as nearly as I can tell what that may be.

If anyone has anything they want conveyed to the committee, please mail
it to me.  I can be reached at the network addresses at the end of this
article, or by paper mail as

	John Quarterman
	Department of Computer Sciences
	University of Texas at Austin
	Austin, Texas 78712

I will also be available at the Portland USENIX (at the Marriott).
If there is sufficient interest, I will try to have a small BOF.

The first committee meeting I will be attending is immediately
before the Portland USENIX, so I cannot yet answer many questions.
I will report on such meetings in net.usenix on USENET, and probably
also in the ;login newsletter, as well as in person at USENIX conferences.
I hope to report what has been decided, what is under consideration,
and, if possible, publish (brief) written position papers from members
of the committee on the various sides of important issues.

Suggestions are welcome.
-- 

John Quarterman, jsq@ut-sally.ARPA, {ihnp4,seismo,ctvax}!ut-sally!jsq

------------------------------

End of Unix Technical Digest
******************************
-- 
Ronald W. Heiby / netnews@wnuxb.UUCP | unix-request@cbosgd.UUCP
AT&T Information Systems, Inc., Lisle, IL  (CU-D21)