Skip to content

Commit d25a7ba

Browse files
committed
devenv: Respect MESON_DISABLE_PS1_OVERRIDE on Windows as well
1 parent a6af0ad commit d25a7ba

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mesonbuild/mdevenv.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ def run(options: argparse.Namespace) -> int:
201201
args = options.devcmd
202202
if not args:
203203
prompt_prefix = f'[{b.project_name}]'
204+
if os.environ.get("MESON_DISABLE_PS1_OVERRIDE"):
205+
prompt_prefix = None
204206
shell_env = os.environ.get("SHELL")
205207
# Prefer $SHELL in a MSYS2 bash despite it being Windows
206208
if shell_env and os.path.exists(shell_env):
@@ -211,8 +213,9 @@ def run(options: argparse.Namespace) -> int:
211213
mlog.warning('Failed to determine Windows shell, fallback to cmd.exe')
212214
if shell in POWERSHELL_EXES:
213215
args = [shell, '-NoLogo', '-NoExit']
214-
prompt = f'function global:prompt {{ "{prompt_prefix} PS " + $PWD + "> "}}'
215-
args += ['-Command', prompt]
216+
if prompt_prefix:
217+
prompt = f'function global:prompt {{ "{prompt_prefix} PS " + $PWD + "> "}}'
218+
args += ['-Command', prompt]
216219
else:
217220
args = [os.environ.get("COMSPEC", r"C:\WINDOWS\system32\cmd.exe")]
218221
args += ['/k', f'prompt {prompt_prefix} $P$G']
@@ -222,7 +225,7 @@ def run(options: argparse.Namespace) -> int:
222225
# Let the GC remove the tmp file
223226
tmprc = tempfile.NamedTemporaryFile(mode='w')
224227
tmprc.write('[ -e ~/.bashrc ] && . ~/.bashrc\n')
225-
if not os.environ.get("MESON_DISABLE_PS1_OVERRIDE"):
228+
if prompt_prefix:
226229
tmprc.write(f'export PS1="{prompt_prefix} $PS1"\n')
227230
for f in bash_completion_files(b, install_data):
228231
tmprc.write(f'. "{f}"\n')

0 commit comments

Comments
 (0)