From d3c74f4f5ded7ef8df964d995b26a4032ec75bf2 Mon Sep 17 00:00:00 2001
From: Javier Maestro <jjmaestro@ieee.org>
Date: Wed, 28 May 2025 18:51:00 +0100
Subject: [PATCH] fix: pgflex - propagate environment to flex subprocess
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Python's subprocess.run docs say that if the env argument is not None,
it will be used "instead of the default behavior of inheriting the
current process’ environment".

However, the environment should be preserved, only adding FLEX_TMP_DIR
to it. For more info, see the following thread:

https://www.postgresql.org/message-id/ot4w2y6es446gjgvhbpp45qt3wx65n5epjxgsu3ghgr63yuizn%40qeurkcofswmv
---
 src/tools/pgflex | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/tools/pgflex b/src/tools/pgflex
index 3986b06874..b8d9aa0086 100755
--- a/src/tools/pgflex
+++ b/src/tools/pgflex
@@ -48,7 +48,7 @@ os.chdir(args.privatedir)
 # contents. Set FLEX_TMP_DIR to the target private directory to avoid
 # that. That environment variable isn't consulted on other platforms, so we
 # don't even need to make this conditional.
-env = {'FLEX_TMP_DIR': args.privatedir}
+os.environ['FLEX_TMP_DIR'] = args.privatedir
 
 # build flex invocation
 command = [args.flex, '-o', args.output_file]
@@ -58,7 +58,7 @@ command += args.flex_flags
 command += [args.input_file]
 
 # create .c file from .l file
-sp = subprocess.run(command, env=env)
+sp = subprocess.run(command)
 if sp.returncode != 0:
     sys.exit(sp.returncode)
 
-- 
2.39.5 (Apple Git-154)

