Commit 81cef571 authored by Julien Muchembled's avatar Julien Muchembled

Improve condition to determine if the output file is executable or not

parent eafa7184
......@@ -107,8 +107,18 @@ class Recipe(object):
output = self.output
rendered = self._render()
mode = self.mode
mask = (0o777 if rendered.startswith(b'#!') else 0o666
) if mode is None else 0
if mode is None:
mask = 0o666
if rendered.startswith(b'#!'):
try:
x = rendered.index(b'\n', 2)
except ValueError:
x = len(rendered)
x = rendered[2:x].split(None, 1)
if x and os.access(x[0], os.X_OK):
mask = 0o777
else:
mask = 0
# Try to reuse existing file. This is particularly
# important to avoid excessive IO because we may render on update.
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment