bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] init.sh: portability fix: use env's POSIX-specified -i optio


From: Jim Meyering
Subject: Re: [PATCH] init.sh: portability fix: use env's POSIX-specified -i option not -u
Date: Tue, 06 Apr 2010 19:26:44 +0200

Eric Blake wrote:

> On 04/06/2010 09:36 AM, Jim Meyering wrote:
>> FYI,
>> I noticed unnecessary mktemp simulation in test logs on Solaris 5.11.
>> This fixes it:
>>
>>    # First, try to use mktemp.
>> -  d=`env -u TMPDIR mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \
>> +  d=`env -i PATH="$PATH" mktemp -d -t -p "$destdir_" "$template_" 
>> 2>/dev/null` \
>
> Even 'env -i' is risky, since you are removing other possibly-important
> variables, like POSIXLY_CORRECT.  Isn't it better to just do:
>
> d=`unset TMPDIR; mktemp -d ...`
>
> and bypass env altogether?

Yes, that reminds me of your reporting that Cygwin
doesn't deal with a cleared environment.  Is that still the case?

Here's the proposed patch:

>From 584308368830f70c1b7b4b129d82457f7a9ca24f Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 6 Apr 2010 19:24:57 +0200
Subject: [PATCH] init.sh: simply unset TMPDIR rather than risking env -i

* tests/init.sh (mktempd_): Using env -i is rather harsh, and
although it probably works fine on all Unix-based systems, some
systems (Cygwin?) cannot tolerate a totally cleared environment.
Suggestion from Eric Blake.

2010-04-06  Jim Meyering  <address@hidden>
---
 ChangeLog     |    8 ++++++++
 tests/init.sh |    2 +-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 60fb413..59cec39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-04-06  Jim Meyering  <address@hidden>

+       init.sh: simply unset TMPDIR rather than risking env -i
+       * tests/init.sh (mktempd_): Using env -i is rather harsh, and
+       although it probably works fine on all Unix-based systems, some
+       systems (Cygwin?) cannot tolerate a totally cleared environment.
+       Suggestion from Eric Blake.
+
+2010-04-06  Jim Meyering  <address@hidden>
+
        init.sh: portability fix: use env's POSIX-specified -i option not -u
        * tests/init.sh (mktempd_): Use env -i and set PATH explicitly rather
        than unportable env -u.  Solaris 5.11's env lacks support for -u.
diff --git a/tests/init.sh b/tests/init.sh
index 9b65129..abfa3b3 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -306,7 +306,7 @@ mktempd_()
   fail=0

   # First, try to use mktemp.
-  d=`env -i PATH="$PATH" mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` 
\
+  d=`unset TMPDIR; mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \
     || fail=1

   # The resulting name must be in the specified directory.
--
1.7.0.4.552.gc303




reply via email to

[Prev in Thread] Current Thread [Next in Thread]