Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions mesonbuild/mdevenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import shutil
import sys
import itertools
import signal
import typing as T

from pathlib import Path
Expand Down Expand Up @@ -224,7 +223,7 @@ def run(options: argparse.Namespace) -> int:
args = [os.environ.get("SHELL", os.path.realpath("/bin/sh"))]
if "bash" in args[0]:
# Let the GC remove the tmp file
tmprc = tempfile.NamedTemporaryFile(mode='w')
tmprc = tempfile.NamedTemporaryFile(mode='w', encoding='utf-8')
tmprc.write('[ -e ~/.bashrc ] && . ~/.bashrc\n')
if prompt_prefix:
tmprc.write(f'export PS1="{prompt_prefix} $PS1"\n')
Expand All @@ -233,25 +232,13 @@ def run(options: argparse.Namespace) -> int:
tmprc.flush()
args.append("--rcfile")
args.append(tmprc.name)
elif args[0].endswith('fish'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SIGINT issue was fixed upstream in 2019 and should be reverted. Don't know about the rest.

# Ignore SIGINT while using fish as the shell to make it behave
# like other shells such as bash and zsh.
# See: https://gitlab.freedesktop.org/gstreamer/gst-build/issues/18
signal.signal(signal.SIGINT, lambda _, __: True)
if prompt_prefix:
args.append('--init-command')
prompt_cmd = f'''functions --copy fish_prompt original_fish_prompt
function fish_prompt
echo -n '[{prompt_prefix}] '(original_fish_prompt)
end'''
args.append(prompt_cmd)
elif args[0].endswith('zsh'):
# Let the GC remove the tmp file
tmpdir = tempfile.TemporaryDirectory()
with open(os.path.join(tmpdir.name, '.zshrc'), 'w') as zshrc: # pylint: disable=unspecified-encoding
with open(os.path.join(tmpdir.name, '.zshrc'), 'w', encoding='utf-8') as zshrc:
zshrc.write('[ -e ~/.zshrc ] && . ~/.zshrc\n')
if prompt_prefix:
zshrc.write(f'export PROMPT="[{prompt_prefix}] $PROMPT"\n')
zshrc.write(f'export PROMPT="{prompt_prefix} $PROMPT"\n')
devenv['ZDOTDIR'] = tmpdir.name
if 'DYLD_LIBRARY_PATH' in devenv and macos_sip_enabled():
mlog.warning('macOS System Integrity Protection is enabled: DYLD_LIBRARY_PATH cannot be set in the subshell')
Expand Down
Loading