home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / mod.std.unix.v8 / text0010.txt < prev    next >
Encoding:
Internet Message Format  |  1987-06-30  |  2.1 KB

  1. From: mayer@rochester.arpa  (Jim Mayer)
  2. Date: Wed, 29 Oct 86 22:15:54 est
  3.  
  4. I have two suggestions that fall into the "new feature" category.  The
  5. first concerns file time manipulation from the shell.  The second
  6. follows from the first, and concerns the combining power of the Bourne shell.
  7.  
  8. There doesn't appear to be any decent way to compare the last modified
  9. times of files from the shell.  I have written programs to do this,
  10. but that makes any scripts I write using the programs essentially
  11. unexportable.
  12.  
  13. There are several approaches to fixing the problem:
  14.  
  15. 1. Extend the "test" command, perhaps by borrowing the "-newer" syntax
  16.    of "find".
  17. 2. Add a new command.  One possibility is
  18.     "isconsistent file other-files..."
  19.    which would return true if the first file was created after all of
  20.    the "other-files".
  21. 3. Resign oneself to writing:
  22.     if [ `ls -t a b | head -1` = a ]
  23.     then echo "a was done later than b"
  24.     fi
  25.  
  26. All three work, however the second points out a problem with the
  27. Bourne shell: there is no "not" operator!
  28.  
  29. If an "isconsistent" command was implemented, then to write code that
  30. (for example) recompiled a C file if the object file was out of date,
  31. one would have to write:
  32.  
  33.     if isconsistent fu.o fu.c
  34.     then true
  35.     else cc -c fu.c
  36.     fi
  37.  
  38. instead of
  39.  
  40.     if ! isconsistent fu.o fu.c
  41.     then cc -c fu.c
  42.     fi
  43.  
  44. Of course, one could always add an "isinconsistent" command, but that
  45. avoids the point.  A "not" command that ran the command specified by
  46. its arguments and inverted the exit code would be better, but would
  47. still not handle things like "if ! (test1 || test2)" easily (I suspose
  48. we could all write in conjunctive normal form (ugh!)).  If there was a
  49. "not" operator then the Bourne shell syntax would be powerful enough
  50. to express arbitrary boolean forms.
  51.  
  52. That, of course, raises the possibility of getting rid of the "test"
  53. command entierly and replacing it with lots of little "gt" and "eq"
  54. commands.  But that's another story.... (and hardly a job for a
  55. standards group!)
  56.  
  57. -- Jim Mayer                    Computer Science Department
  58. (arpa) mayer@Rochester.EDU            University of Rochester
  59. (uucp) rochester!mayer                Rochester, New York 14627
  60.  
  61.  
  62. Volume-Number: Volume 8, Number 11
  63.  
  64.