Simplify command call, no need to wrap this in a dummy 'sh -c'

This commit is contained in:
Alexandre Aubin 2020-12-05 20:28:45 +01:00
parent 14f6f09993
commit d6d45cf7a6

View file

@ -390,18 +390,15 @@ def _hook_exec_bash(path, args, chdir, env, return_format, loggers):
f.write('')
env['YNH_STDRETURN'] = stdreturn
# Construct command to execute
command = ['sh', '-c']
# use xtrace on fd 7 which is redirected to stdout
cmd = 'BASH_XTRACEFD=7 /bin/bash -x "{script}" {args} 7>&1'
env['BASH_XTRACEFD'] = 7
cmd = '/bin/bash -x "{script}" {args} 7>&1'
cmd = cmd.format(script=cmd_script, args=cmd_args)
command.append(cmd.format(script=cmd_script, args=cmd_args))
logger.debug("Executing command '%s'" % ' '.join(command))
logger.debug("Executing command '%s'" % cmd)
returncode = call_async_output(
command, loggers, shell=False, cwd=chdir,
cmd, loggers, shell=True, cwd=chdir,
stdinfo=stdinfo, env=env
)