aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-11-29 20:52:12 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-11-29 21:30:57 +0530
commitabcace7ee14a28e7f79329a41f5ae49533cbcd0d (patch)
tree42a1aab275934ecbd6433a929118a69f1095029d /mesonbuild
parent120f7a4c4009990b2eed70ffbf019b5f7daf8268 (diff)
downloadmeson-abcace7ee14a28e7f79329a41f5ae49533cbcd0d.zip
meson-abcace7ee14a28e7f79329a41f5ae49533cbcd0d.tar.gz
meson-abcace7ee14a28e7f79329a41f5ae49533cbcd0d.tar.bz2
dependencies: Fix parsing of shebangs with spaces
While finding an external program, we should only split the shebang once since that is what Linux and BSD also do. This is also why everyone uses #!/usr/bin/env in their shebangs since that allows you to run an interpreter in a path with spaces in it. See `man execve` for more details, specifically the sections for interpreter scripts.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/dependencies/base.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 682182c..a720232 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -560,7 +560,11 @@ class ExternalProgram:
with open(script) as f:
first_line = f.readline().strip()
if first_line.startswith('#!'):
- commands = first_line[2:].split('#')[0].strip().split()
+ # In a shebang, everything before the first space is assumed to
+ # be the command to run and everything after the first space is
+ # the single argument to pass to that command. So we must split
+ # exactly once.
+ commands = first_line[2:].split('#')[0].strip().split(maxsplit=1)
if mesonlib.is_windows():
# Windows does not have UNIX paths so remove them,
# but don't remove Windows paths