Web lists-archives.com

Re: [PATCH 3/3] t0006-date.sh: add `human` date format tests.




Am 09.01.19 um 01:44 schrieb Stephen P. Smith:
On Tuesday, January 8, 2019 2:27:22 PM MST Johannes Sixt wrote:
Am 31.12.18 um 01:31 schrieb Stephen P. Smith:
+
+TODAY_REGEX='[A-Z][a-z][a-z] [012][0-9]:[0-6][0-9] .0200'
<snip>
The $...REGEX expansions must be put in double-quotes to protect them
from field splitting. But then the tests do not pass anymore (I tested
only t4202). Please revisit this change.

I will later figure out why you are seeing the fields splitting but I am not.
In the mean time I will change the quoting.

In this line

TODAY_REGEX='[A-Z][a-z][a-z] [012][0-9]:[0-6][0-9] .0200'

no field splitting occurs. The quoting is fine here. But notice that the value of $TODAY_REGEX contains blanks.

In this line

check_human_date "$(($(date +%s)-18000)) +0200" $TODAY_REGEX

the value of $TODAY_REGEX is substituted and then the value is split into fields at the blanks because the expansion is not quoted.

As a consequence, function check_human_date considers only the first part of $TODAY_REGEX, i.e. 'A-Z][a-z][a-z]' (which is parameter $2), but ignores everything else (because it does not use $3 or $4).

-- Hannes