home *** CD-ROM | disk | FTP | other *** search
- 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
-
-