🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: mod.std.unix
Article #364

file times and shell commands

#364
From: Moderator, John Quarterman
Date: Fri, 31 Oct 1986 01:39
62 lines
2780 bytes
From: mayer@rochester.arpa  (Jim Mayer)
Date: Wed, 29 Oct 86 22:15:54 est

I have two suggestions that fall into the "new feature" category.  The
first concerns file time manipulation from the shell.  The second
follows from the first, and concerns the combining power of the Bourne shell.

There doesn't appear to be any decent way to compare the last modified
times of files from the shell.  I have written programs to do this,
but that makes any scripts I write using the programs essentially
unexportable.

There are several approaches to fixing the problem:

1. Extend the "test" command, perhaps by borrowing the "-newer" syntax
   of "find".
2. Add a new command.  One possibility is
	"isconsistent file other-files..."
   which would return true if the first file was created after all of
   the "other-files".
3. Resign oneself to writing:
	if [ `ls -t a b | head -1` = a ]
	then echo "a was done later than b"
	fi

All three work, however the second points out a problem with the
Bourne shell: there is no "not" operator!

If an "isconsistent" command was implemented, then to write code that
(for example) recompiled a C file if the object file was out of date,
one would have to write:

	if isconsistent fu.o fu.c
	then true
	else cc -c fu.c
	fi

instead of

	if ! isconsistent fu.o fu.c
	then cc -c fu.c
	fi

Of course, one could always add an "isinconsistent" command, but that
avoids the point.  A "not" command that ran the command specified by
its arguments and inverted the exit code would be better, but would
still not handle things like "if ! (test1 || test2)" easily (I suspose
we could all write in conjunctive normal form (ugh!)).  If there was a
"not" operator then the Bourne shell syntax would be powerful enough
to express arbitrary boolean forms.

That, of course, raises the possibility of getting rid of the "test"
command entierly and replacing it with lots of little "gt" and "eq"
commands.  But that's another story.... (and hardly a job for a
standards group!)

-- Jim Mayer					Computer Science Department
(arpa) mayer@Rochester.EDU			University of Rochester
(uucp) rochester!mayer				Rochester, New York 14627


Volume-Number: Volume 8, Number 11
Technical Details
Message-ID: <6177@ut-sally.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ut-sally!std-unix

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ut-sally!std-unix
From: std-unix@ut-sally.UUCP (Moderator, John Quarterman)
Newsgroups: mod.std.unix
Subject: file times and shell commands
Message-ID: <6177@ut-sally.UUCP>
Date: Thu, 30-Oct-86 20:39:06 EST
Article-I.D.: ut-sally.6177
Posted: Thu Oct 30 20:39:06 1986
Date-Received: Fri, 31-Oct-86 03:28:17 EST
Organization: IEEE P1003 Portable Operating System for Computer Environments Committee
Lines: 62
Approved: jsq@sally.utexas.edu