Skip to contentSkip to conversation

configure.ac: replace set with env

PATCH In review Christian Hesse 4 participants 5 messages Jan 6, 2020 – Jun 23, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure.ac: replace set with env

From: Christian Hesse <[email protected]...>

The shell builtin set produces different output for different shells:

bash$ set | grep '^TERM='
TERM=xterm
dash$ set | grep '^TERM='
TERM='xterm'

This may break reproducible builds depending on what shell is used.

Let's replace set with env, which is a real command and always produces identical output.

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
index a47e0a06..f13ff7b6 100644
@@ -1326,7 +1326,7 @@ if test "${enable_async_push}" = "yes"; then
 	)
 fi
 
-CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
+CONFIGURE_DEFINES="`env | grep '^enable_.*=' ; env | grep '^with_.*='`"
 AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["`echo ${CONFIGURE_DEFINES}`"], [Configuration settings])
 
 TAP_WIN_COMPONENT_ID="PRODUCT_TAP_WIN_COMPONENT_ID"
#1 lore raw

How about printenv (without grep)?
________________________________
From: Christian Hesse <[email protected]...>
Sent: Monday, January 6, 2020 4:04:26 PM
To: OpenVPN Development <[email protected]>
Cc: Christian Hesse <[email protected]...>
Subject: [Openvpn-devel] [PATCH 1/1] configure.ac: replace set with env

From: Christian Hesse <[email protected]...>

The shell builtin set produces different output for different shells:

bash$ set | grep '^TERM='
TERM=xterm
dash$ set | grep '^TERM='
TERM='xterm'

This may break reproducible builds depending on what shell is used.

Let's replace set with env, which is a real command and always produces identical output.

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
index a47e0a06..f13ff7b6 100644
@@ -1326,7 +1326,7 @@ if test "${enable_async_push}" = "yes"; then
         )
 fi
 
-CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
+CONFIGURE_DEFINES="`env | grep '^enable_.*=' ; env | grep '^with_.*='`"
 AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["`echo ${CONFIGURE_DEFINES}`"], [Configuration settings])
 
 TAP_WIN_COMPONENT_ID="PRODUCT_TAP_WIN_COMPONENT_ID"

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#2 lore raw

Tom Yan <[email protected]...> on Mon, 2020/01/06 08:48:

Quoted 1 line

How about printenv (without grep)?

The variables are not known in advance. This needs to match all variables starting with "enable_" and "with_".

Signature · 3 lines
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Best regards             my address:    */=0;b=c[a++];)
putchar(b-1/(/*    Chris            cc -ox -xc - && ./x    */b/42*2-3)*42);}
#3 lore raw
In reply to Tom Yan

Hi,

Quoted 1 line · Tom Yan

How about printenv (without grep)?

Portability.

"env |grep" is POSIX standardized so should work everywhere.

printenv is a BSD invention, which not all unix variants are required to have.

(Besides, printenv on its own cannot do "give me all environment variables that start with 'with_'", which is exactly what we want here... so you'd end up with "printenv | grep", which is less portable and more characters)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#4 lore raw
In reply to Christian Hesse
Quoted 9 lines · Christian Hesse

From: Christian Hesse <[email protected]...>

The shell builtin set produces different output for different shells:

bash$ set | grep '^TERM='
TERM=xterm
dash$ set | grep '^TERM='
TERM='xterm'

Quoted 4 lines

This may break reproducible builds depending on what shell is used.

Let's replace set with env, which is a real command and always produces identical output.

Hi,

Spotted this one now, lingering for way too long. And it looked trivial. Except it doesn't give the expected outcome on my RHEL-8 machine. The CONFIGURE_DEFINES macro in config.h ends up empty. Reverting this patch alone, and it comes back again.

So, I'm sorry, I can't ack this one.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc