bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test -nt not sane


From: Chet Ramey
Subject: Re: test -nt not sane
Date: Wed, 10 Aug 2011 15:25:49 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11

On 8/10/11 2:53 PM, Curtis Doty wrote:
> Or maybe I'm not groking. When one compares against a b0rk symlink, the
> result of -nt (newer than) is true--when it isn't!
> 
>   mkdir directory
>   ln -s noexist symlink
>   touch -hr directory symlink
> 
>   test directory -nt symlink &&echo yes ||echo no
> 
> They have identical mtimes (as set by touch)--i.e. the directory is *not*
> newer than the symlink--but it still outputs "yes". Why?

The man page says:

Unless otherwise specified, primaries that operate on files follow sym-
bolic links and operate on the target of the link, rather than the link
itself.

and

file1 -nt file2
      True if file1 is newer (according  to  modification  date)  than
      file2, or if file1 exists and file2 does not.

file1 exists. file2 does not.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]