Fix recursive definitions in env vars not expanded

This commit is contained in:
Kovid Goyal
2022-03-07 11:07:26 +05:30
parent 6ff69c88df
commit 68df13d3fe
3 changed files with 21 additions and 5 deletions

View File

@@ -8,8 +8,8 @@ import getpass
import io
import os
import pwd
import re
import select
import shlex
import shutil
import subprocess
import sys
@@ -72,6 +72,10 @@ def debug(msg):
write_all(tty_fd, data)
def unquote_env_val(x):
return re.sub('\\\\([\\$`"\n])', r'\1', x[1:-1])
def apply_env_vars(raw):
global login_shell
@@ -81,7 +85,7 @@ def apply_env_vars(raw):
key, val = parts[0], ''
else:
key, val = parts
val = shlex.split(val)[0]
val = os.path.expandvars(unquote_env_val(val))
os.environ[key] = val
for line in raw.splitlines():