std-unix@ut-sally.UUCP (Moderator, John Quarterman) (11/04/86)
From: gwyn@brl.arpa (VLD/VMB) (Douglas A. Gwyn) Date: Mon, 3 Nov 86 10:37:13 EST /* newer -- test file modification dates last edit: 86/03/30 D A Gwyn */ #ifndef lint static char SCCS_ID[] = "@(#)newer.c 1.1"; #endif #include <sys/types.h> #include <sys/stat.h> #define EXIT _exit /* non-STDIO exit(), if available */ #define STDERR 2 /* standard error file descriptor */ extern void EXIT(); extern int stat(), write(); main( argc, argv ) int argc; char *argv[]; { static char usage[] = "Usage: newer file1 file2\n"; static struct stat file1; /* file1 statistics */ static struct stat file2; /* file2 statistics */ if ( argc != 3 ) { /* wrong number of arguments */ (void)write( STDERR, usage, sizeof usage - 1 ); EXIT( 3 ); } if ( stat( argv[1], &file1 ) != 0 ) EXIT( 2 ); /* file1 doesn't exist */ if ( stat( argv[2], &file2 ) != 0 ) EXIT( 0 ); /* file2 doesn't exist */ #ifdef lint return file1.st_mtime < file2.st_mtime ? 1 : 0; #else EXIT( file1.st_mtime < file2.st_mtime ? 1 : 0 ); #endif } Volume-Number: Volume 8, Number 29
std-unix@ut-sally.UUCP (Moderator, John Quarterman) (11/06/86)
From: harvard!ho3cad!ekb (Eric Bustad) Date: Wed, 5 Nov 86 15:40:42 CST This version of "newer" will say that one file is newer that the other when they are both exactly the same age. Is this a bug or does the V8 version of "newer" act this way also? = Eric Bustad AT&T Bell Laboratories Holmdel NJ 07733-1988 (201)949-6257 ekb@ho3cad.ATT.COM or ihnp4!ho3cad!ekb Volume-Number: Volume 8, Number 44
std-unix@ut-sally.UUCP (Moderator, John Quarterman) (11/07/86)
From: gwyn@brl.arpa (VLD/VMB) (Douglas A. Gwyn) Date: Thu, 6 Nov 86 18:48:26 EST The 8th Ed. UNIX manual says that a zero return code is returned if the first file's mod time is AT LEAST AS RECENT as the second's (as well as under other circumstances). I take this to mean that in case of an exact tie, the first file is considered "newer" than the second. I don't know why it's specified this way. Volume-Number: Volume 8, Number 45
std-unix@ut-sally.UUCP (Moderator, John Quarterman) (11/07/86)
From: pyramid!utzoo!henry (Henry Spencer) Date: Thu, 6 Nov 86 20:53:27 CST > This version of "newer" will say that one file is newer that the > other when they are both exactly the same age. Is this a bug or > does the V8 version of "newer" act this way also? The V8 newer does in fact return success (exit status 0) when the files are exactly the same age. The name is not entirely right; it should be something like "up_to_date_with", in an ideal world. The behavior would not appear to be a bug, since it is consistent with the wording of the manual page. Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,decvax,pyramid}!utzoo!henry Volume-Number: Volume 8, Number 46