mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
touch: ignore "-d now" option, when appropriate
* src/touch.c (main): Treat "-d now" as if it were absent, if neither -a nor -m is specified. Problem reported by Dan Jacobson in: http://lists.gnu.org/archive/html/bug-coreutils/2008-01/msg00010.html
This commit is contained in:
1 parent
6efd10462d
commit
fd12e98f36
2 files changed
+28
-1
No files matched your search
@@ -1,3 +1,10 @@
|
||||
2008-01-06 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
touch: ignore "-d now" option, when appropriate
|
||||
* src/touch.c (main): Treat "-d now" as if it were absent, if
|
||||
neither -a nor -m is specified. Problem reported by Dan Jacobson in:
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2008-01/msg00010.html
|
||||
|
||||
2008-01-05 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Avoid tr case-conversion failure in some locales.
|
||||
|
||||
+21
-1
@@ -368,9 +368,29 @@ main (int argc, char **argv)
|
||||
{
|
||||
if (flex_date)
|
||||
{
|
||||
get_reldate (&newtime[0], flex_date, NULL);
|
||||
struct timespec now;
|
||||
gettime (&now);
|
||||
get_reldate (&newtime[0], flex_date, &now);
|
||||
newtime[1] = newtime[0];
|
||||
date_set = true;
|
||||
|
||||
/* If neither -a nor -m is specified, treat "-d now" as if
|
||||
it were absent; this lets "touch" succeed more often in
|
||||
the presence of restrictive permissions. */
|
||||
if (change_times == (CH_ATIME | CH_MTIME)
|
||||
&& newtime[0].tv_sec == now.tv_sec
|
||||
&& newtime[0].tv_nsec == now.tv_nsec)
|
||||
{
|
||||
/* Check that it really was "-d now", and not a time
|
||||
stamp that just happens to be the current time. */
|
||||
struct timespec notnow, notnow1;
|
||||
notnow.tv_sec = now.tv_sec ^ 1;
|
||||
notnow.tv_nsec = now.tv_nsec;
|
||||
get_reldate (¬now1, flex_date, ¬now);
|
||||
if (notnow1.tv_sec == notnow.tv_sec
|
||||
&& notnow1.tv_nsec == notnow.tv_nsec)
|
||||
date_set = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user