[PATCH] Port better to POSIX 'touch'
* Makefile (set-timestamps.out): Use POSIX syntax for 'touch -d' rather than relying on a GNU extension. --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 17e73891..d891f837 100644 --- a/Makefile +++ b/Makefile @@ -988,8 +988,11 @@ set-timestamps.out: $(EIGHT_YARDS) rm -f test.out && \ for file in $$files; do \ if git diff --quiet $$file; then \ - time=`git log -1 --format='tformat:%ct' $$file` && \ - touch -cmd @$$time $$file; \ + time=`TZ=UTC0 git log -1 \ + --format='tformat:%cd' \ + --date='format:%Y-%m-%dT%H:%M:%SZ' \ + $$file` && \ + touch -cmd $$time $$file; \ else \ echo >&2 "$$file: warning: does not match repository"; \ fi || exit; \ -- 2.39.2
On 2023-07-24 13:45, Paul Eggert via tz wrote:
* Makefile (set-timestamps.out): Use POSIX syntax for 'touch -d' rather than relying on a GNU extension. --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index 17e73891..d891f837 100644 --- a/Makefile +++ b/Makefile @@ -988,8 +988,11 @@ set-timestamps.out: $(EIGHT_YARDS) rm -f test.out && \ for file in $$files; do \ if git diff --quiet $$file; then \ - time=`git log -1 --format='tformat:%ct' $$file` && \ - touch -cmd @$$time $$file; \ + time=`TZ=UTC0 git log -1 \ + --format='tformat:%cd' \ + --date='format:%Y-%m-%dT%H:%M:%SZ' \ + $$file` && \
Would the built-in ISO format %cI e.g. 2023-07-24T12:44:34-07:00 not be clearer: time=`git log -1 --format=%cI $$file` && \
+ touch -cmd $$time $$file; \ else \ echo >&2 "$$file: warning: does not match repository"; \ fi || exit; \
-- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry
On 2023-07-24 16:55, Paul Eggert wrote:
On 2023-07-24 13:59, Brian Inglis via tz wrote:
Would the built-in ISO format %cI e.g. 2023-07-24T12:44:34-07:00 not be clearer:
POSIX 'touch' doesn't support that format.
Thanks Paul, I was not aware most BSD derived implementations and POSIX supported -d only with that ISO variant: you have spoiled us with coreutils date-time support ;^> I use (Cygwin coreutils) touch to back/future date historical, expected, and expiry dates on family pics, documents, and files, and many MS GUI interfaces and utilities seem to be unhappy using the full range of NTFS file date-times 1601-01-01..30828-09-14! ;^> -- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry
participants (2)
-
Brian Inglis -
Paul Eggert