johnsonjh / isnewer

isnewer: A utility to compare file modification dates; re-implementation of AT&T Research UNIX V8 newer(1)

Home Page:https://github.com/johnsonjh/isnewer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

isnewer - compare file modification dates

A free implementation of AT&T Research UNIX V8 newer(1).

Overview

  • It is unfortunately difficult to portably and robustly determine the newer of two files from a UNIX shell script - the POSIX baseline test(1) does not include the -nt and -ot operators commonly seen on GNU and BSD systems. Efforts to update the POSIX specification to include these and other widely-implemented test(1) extensions appears to have stalled.

  • AT&T Research UNIX V8 (never released under a proper FLOSS license) from 1985 offers a reasonable precedent, having provided this functionality via the newer(1) shell utility:

      NAME
           newer - test file modification dates
    
      SYNOPSIS
           newer file1 file2
    
      DESCRIPTION
           Newer yields a zero return code if file1 exists and file2
           does not, or if file1 and file2 both exist and file1's
           modification time is at least as recent as that of file2.
           It yields a non-zero return code otherwise.
    
  • isnewer intends to be compatible with the AT&T Research UNIX V8 newer(1) implementation, with the addition of supporting the following command-line arguments:

    • -v or --version - Prints version information to standard error
    • -h or --help - Prints usage information to standard error
  • These new arguments are exclusive; that is, they may not combined with each other and may not be used in conjunction with any date comparisons.

  • The name isnewer was chosen for this package to avoid clashing with other utilities of the same name that may be provided by operating systems (i.e. Research UNIX V8) or as components of other packages (i.e. some versions of teTeX). Users, system administrators, and distribution packagers can make use of alternatives or a similar facility to provide more convenient access to this utility.

Building

  • isnewer should work on any POSIX-like system with a C compiler.
  • A convenient Makefile for building and running tests is provided.

Notes

License

  • isnewer is distributed under the terms and conditions of the following Zero-Clause BSD (0BSD) license.

    Copyright (c) 2022 Jeffrey H. Johnson <trnsz@pobox.com>
    
    Permission to use, copy, modify, and/or distribute this software for
    any purpose with or without fee is hereby granted.
    
    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
    MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    

About

isnewer: A utility to compare file modification dates; re-implementation of AT&T Research UNIX V8 newer(1)

https://github.com/johnsonjh/isnewer

License:BSD Zero Clause License


Languages

Language:Makefile 57.6%Language:C 42.4%