From patchwork Thu Jun 22 08:30:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UGV0ciBTa2/EjcOtaw==?= X-Patchwork-Id: 9803765 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D480760329 for ; Thu, 22 Jun 2017 08:30:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5A6028686 for ; Thu, 22 Jun 2017 08:30:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B93332866D; Thu, 22 Jun 2017 08:30:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6767F2867F for ; Thu, 22 Jun 2017 08:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751130AbdFVIaE (ORCPT ); Thu, 22 Jun 2017 04:30:04 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33885 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbdFVIaD (ORCPT ); Thu, 22 Jun 2017 04:30:03 -0400 Received: by mail-lf0-f68.google.com with SMTP id l200so1190372lfg.1 for ; Thu, 22 Jun 2017 01:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:disposition-notification-to:date :user-agent:mime-version:content-language:content-transfer-encoding; bh=IQs5xY3fqunJWPBN5Jje955CyHAzNQDSHI7DfUBnDy0=; b=tsARnhpoC6JwnkwxLQTXR7eL0PlAoNkIEfR92FtfSWQJMV11Qgcu9rGvkVbE5b/Akx has39ZOto4/a4POSKAjd9Zh/lefs/jp8X7dORXDidOJItYCg9MLAvu0+tMeibzLJ7hMV naURhegOWcpiwAoZf1ijWxffBrZnKvTqLx5NpMfYyx1t3wZGq+n5R4hfeODXu3L8SuMN ekkeuWsCk3Ok0Rrr2zmKwAJS+Nk5fZLuzfQbW9RBGbVybUfOlAwOAwXrfQ324SBkUh4F JDJ0MPzZF4/+SMcSnohIW5tntcGVaYpIoJKXTz1WffyWP4/YMEv/vCrL6hZDYcLRzA7r /MKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id :disposition-notification-to:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=IQs5xY3fqunJWPBN5Jje955CyHAzNQDSHI7DfUBnDy0=; b=fx4aSLas0Ei6MAgONpBqCgZ4fig0UxePu8szIvkfyx1ULBdpn+lawg16oTQCGD8seq nlmiJHpZ9e8KQZ3HW7LPDFaKZgSgtCt0vRyhRHe44KeA4q3A26dxWEfk/vn9a9vRnaOA SQ7BLYSQe+dWHHNCs1TzO4zAXD/LwRQlFaU+mS+piOZqnuacLgVeMJwriwrG3RGFPbER re9WgEQAE8PXPOZOuyLT5P9QFxr8hFxk03Z6NNqG4Gzj/2FVNqdecqZBv3o5INB9MuoI oVw5KT7DfxyOTy2esk8tSDnnAx71PE5gcndx9XwKeiYggksDdBj1g48R3yxZvZ0FIlj8 arBQ== X-Gm-Message-State: AKS2vOzi7Oqo5KIjcQNNSmXgTi99X/Vs0UB14C4LluIpuSmhXG7q0zTw 19BILB6zSz+X+TJOuas= X-Received: by 10.80.158.102 with SMTP id z93mr494222ede.144.1498120201813; Thu, 22 Jun 2017 01:30:01 -0700 (PDT) Received: from [10.10.0.2] (147.213.broadband18.iol.cz. [109.81.213.147]) by smtp.googlemail.com with ESMTPSA id r28sm558845edd.33.2017.06.22.01.30.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 01:30:00 -0700 (PDT) To: dash@vger.kernel.org From: =?UTF-8?B?UGV0ciBTa2/EjcOtaw==?= Subject: Greater resolution in test -nt / test -ot Message-ID: <9903b02c-041f-38b6-e510-06b9f8744fbb@gmail.com> Date: Thu, 22 Jun 2017 10:30:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 Content-Language: en-US Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, would you be willing to pull something like this? static int @@ -488,7 +490,9 @@ olderf (const char *f1, const char *f2) return (stat (f1, &b1) == 0 && stat (f2, &b2) == 0 && - b1.st_mtime < b2.st_mtime); + (b1.st_mtim.tv_sec < b2.st_mtim.tv_sec || + (b1.st_mtim.tv_sec == b2.st_mtim.tv_sec && (b1.st_mtim.tv_nsec < b2.st_mtim.tv_nsec ))) + ); } static int I could use greater resolution in `test -nt` / `test -ot`, and st_mtim field is standardized under POSIX.1-2008 (or so stat(2) says). Best Regards, Petr Skocik --- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/src/bltin/test.c b/src/bltin/test.c index 58c05fe..7ea02f2 100644 --- a/src/bltin/test.c +++ b/src/bltin/test.c @@ -478,7 +478,9 @@ newerf (const char *f1, const char *f2) return (stat (f1, &b1) == 0 && stat (f2, &b2) == 0 && - b1.st_mtime > b2.st_mtime); + ( b1.st_mtim.tv_sec > b2.st_mtim.tv_sec || + (b1.st_mtim.tv_sec == b2.st_mtim.tv_sec && (b1.st_mtim.tv_nsec > b2.st_mtim.tv_nsec ))) + ); }