Since we only care about shebang line and sane ones use plain ASCII, use an encoding that can not fail. Closes #561.

pull/574/head
Jussi Pakkanen 9 years ago
parent d3d37c4296
commit aac7f6ef1f
  1. 3
      mesonbuild/scripts/meson_install.py

@ -110,7 +110,7 @@ def run_install_script(d):
print('Running custom install script %s' % script) print('Running custom install script %s' % script)
suffix = os.path.splitext(script)[1].lower() suffix = os.path.splitext(script)[1].lower()
if platform.system().lower() == 'windows' and suffix != '.bat': if platform.system().lower() == 'windows' and suffix != '.bat':
first_line = open(script).readline().strip() first_line = open(script, encoding='latin_1', errors='ignore').readline().strip()
if first_line.startswith('#!'): if first_line.startswith('#!'):
if shutil.which(first_line[2:]): if shutil.which(first_line[2:]):
commands = [first_line[2:]] commands = [first_line[2:]]
@ -118,7 +118,6 @@ def run_install_script(d):
commands = first_line[2:].split('#')[0].strip().split() commands = first_line[2:].split('#')[0].strip().split()
commands[0] = shutil.which(commands[0].split('/')[-1]) commands[0] = shutil.which(commands[0].split('/')[-1])
if commands[0] is None: if commands[0] is None:
commands
raise RuntimeError("Don't know how to run script %s." % script) raise RuntimeError("Don't know how to run script %s." % script)
final_command = commands + [script] + i.cmd_arr[1:] final_command = commands + [script] + i.cmd_arr[1:]
else: else:

Loading…
Cancel
Save