[tz] [PATCH] Port better to POSIX 'touch'

Brian Inglis Brian.Inglis at Shaw.ca
Mon Jul 24 20:59:44 UTC 2023


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



More information about the tz mailing list