# [PATCH] Unset TZ in t5000

6 messages from 2005-06-13 to 2005-06-14. Participants: Mark Allen, Rene Scharfe.
Thread: https://gitlist.dev/t/920

## Mark Allen, 2005-06-13 00:24

Subject: [PATCH] Unset TZ in t5000
Message-ID: <20050613002444.80848.qmail@web41213.mail.yahoo.com>
URL: https://gitlist.dev/e/20050613002444.80848.qmail%40web41213.mail.yahoo.com

```
Unset TZ in t5000 and remove GNU awkism

The t5000 test script fails at test #4 on my box because my copy of tar adjusts the time
in the tarfile for local time if TZ is set. Explicitly unset TZ so that it reports GMT
time.  Additionally, my version of AWK doesn't like the "length" directive, so this patch
removes it.

Signed-off-by: Mark Allen <mrallen1@yahoo.com>

diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -50,8 +50,8 @@ test_expect_success \
 
 test_expect_success \
     'validate file modification time' \
-    'tar tvf b.tar a/a |
-     awk \{print\ \$4,\ length\(\$5\)\<7\ ?\ \$5\":00\"\ :\ \$5\} >b.mtime &&
+    'TZ= tar tvf b.tar a/a |
+     awk \{print\ \$4\"\ \"\$5\} >b.mtime &&
      echo "2005-05-27 22:00:00" >expected.mtime &&
      diff expected.mtime b.mtime'

```

## Rene Scharfe, 2005-06-13 15:54

Subject: Re: [PATCH] Unset TZ in t5000
Message-ID: <42ADAC4D.7050408@lsrfire.ath.cx>
URL: https://gitlist.dev/e/42ADAC4D.7050408%40lsrfire.ath.cx
In-Reply-To: <20050613002444.80848.qmail@web41213.mail.yahoo.com>

```
Mark Allen schrieb:
> Unset TZ in t5000 and remove GNU awkism
> 
> The t5000 test script fails at test #4 on my box because my copy of 
> tar adjusts the time in the tarfile for local time if TZ is set. 
> Explicitly unset TZ so that it reports GMT time.

Good idea.

> Additionally, my version of AWK doesn't like the "length" directive, 
> so this patch removes it.

What kind of AWK is that?  The One True AWK certainly has a length
function for strings and POSIX mandates it, too, so it's not a GNUism.

The expression

   length($5)<7 ? $5":00" : $5

(where $5 is a time value) is there to cope with tars that format the
time like hh:mm instead of the expected hh:mm:ss.  If you have to remove
the call to "length", please replace the thing with something
equivalent, like

   match($5, /:.*:/) ? $5 : $5":00"

or similar, instead of simply dropping that test.

Thanks,
Rene

```

## Mark Allen, 2005-06-13 17:27

Subject: Re: [PATCH] Unset TZ in t5000
Message-ID: <20050613172757.41222.qmail@web41215.mail.yahoo.com>
URL: https://gitlist.dev/e/20050613172757.41222.qmail%40web41215.mail.yahoo.com
In-Reply-To: <42ADAC4D.7050408@lsrfire.ath.cx>

```
--- Rene Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
> What kind of AWK is that?  The One True AWK certainly has a length
> function for strings and POSIX mandates it, too, so it's not a GNUism.
> 
> The expression
> 
>    length($5)<7 ? $5":00" : $5
> 
> (where $5 is a time value) is there to cope with tars that format the
> time like hh:mm instead of the expected hh:mm:ss.  If you have to remove
> the call to "length", please replace the thing with something
> equivalent, like
> 
>    match($5, /:.*:/) ? $5 : $5":00"
> 
> or similar, instead of simply dropping that test.

Hi Rene,

I'll test your suggestion later tonight (US time) when I get home from work.  Sorry I
don't know much about awk. (I usually break out perl for any job I used to give awk) When
I ran the t5000 script in --verbose mode, all I could see was awk complaining about the
length directive.

It *is* possible that there's some kind of quoting/character escape problem which Linux
tolerates but is causing the syntax error on my home system. (It's Mac OS 10.4.1/Darwin)

Thanks,

--Mark

```

## Mark Allen, 2005-06-14 13:17

Subject: Re: [PATCH] Unset TZ in t5000
Message-ID: <20050614131727.23011.qmail@web41211.mail.yahoo.com>
URL: https://gitlist.dev/e/20050614131727.23011.qmail%40web41211.mail.yahoo.com
In-Reply-To: <42ADAC4D.7050408@lsrfire.ath.cx>

```
--- Rene Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:> Mark Allen schrieb:
 > The expression
> 
>    length($5)<7 ? $5":00" : $5
> 
> (where $5 is a time value) is there to cope with tars that format the
> time like hh:mm instead of the expected hh:mm:ss.

I put (escaped) parenthesis around the length function and now it works as expected.
Here's a new patch. Please ack if you approve. 

Thanks,

--Mark

Signed-off-by: Mark Allen <mrallen1@yahoo.com>



diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -50,8 +50,9 @@ test_expect_success \
 
 test_expect_success \
     'validate file modification time' \
-    'tar tvf b.tar a/a |
-     awk \{print\ \$4,\ length\(\$5\)\<7\ ?\ \$5\":00\"\ :\ \$5\} >b.mtime &&
+    'TZ= tar tvf b.tar a/a |
+     awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
+     >b.mtime &&
      echo "2005-05-27 22:00:00" >expected.mtime &&
      diff expected.mtime b.mtime'
 

```

## Rene Scharfe, 2005-06-14 15:17

Subject: Re: [PATCH] Unset TZ in t5000
Message-ID: <42AEF512.5040107@lsrfire.ath.cx>
URL: https://gitlist.dev/e/42AEF512.5040107%40lsrfire.ath.cx
In-Reply-To: <20050614131727.23011.qmail@web41211.mail.yahoo.com>

```
Mark Allen schrieb:
> --- Rene Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:> Mark Allen schrieb:
>  > The expression
> 
>>   length($5)<7 ? $5":00" : $5
>>
>>(where $5 is a time value) is there to cope with tars that format the
>>time like hh:mm instead of the expected hh:mm:ss.
> 
> 
> I put (escaped) parenthesis around the length function and now it works as expected.
> Here's a new patch. Please ack if you approve. 
> 
> Thanks,
> 
> --Mark
> 
> Signed-off-by: Mark Allen <mrallen1@yahoo.com>
> 
> 
> ------------------------------------------------------------------------
> 
> diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
> --- a/t/t5000-tar-tree.sh
> +++ b/t/t5000-tar-tree.sh
> @@ -50,8 +50,9 @@ test_expect_success \
>  
>  test_expect_success \
>      'validate file modification time' \
> -    'tar tvf b.tar a/a |
> -     awk \{print\ \$4,\ length\(\$5\)\<7\ ?\ \$5\":00\"\ :\ \$5\} >b.mtime &&
> +    'TZ= tar tvf b.tar a/a |
> +     awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
> +     >b.mtime &&
>       echo "2005-05-27 22:00:00" >expected.mtime &&
>       diff expected.mtime b.mtime'
>  

Acked-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>

```

## Mark Allen, 2005-06-14 17:09

Subject: Re: [PATCH] Unset TZ in t5000
Message-ID: <20050614170939.69223.qmail@web41206.mail.yahoo.com>
URL: https://gitlist.dev/e/20050614170939.69223.qmail%40web41206.mail.yahoo.com
In-Reply-To: <42AEF512.5040107@lsrfire.ath.cx>

```
Linus,

Please apply this patch to make t5000 more portable.

Thanks,

--Mark

---

Unset TZ to force GMT in test #4 and add a set of parens around
the length function in the awk script.

Signed-off-by: Mark Allen <mrallen1@yahoo.com>
Acked-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
 


diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -50,8 +50,9 @@ test_expect_success \
 
 test_expect_success \
     'validate file modification time' \
-    'tar tvf b.tar a/a |
-     awk \{print\ \$4,\ length\(\$5\)\<7\ ?\ \$5\":00\"\ :\ \$5\} >b.mtime &&
+    'TZ= tar tvf b.tar a/a |
+     awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
+     >b.mtime &&
      echo "2005-05-27 22:00:00" >expected.mtime &&
      diff expected.mtime b.mtime'
 

```
