diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-12-08 21:12:16 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-12-08 21:12:55 +0100 |
commit | 70a9839743280edf915c356c309991fba6d7790d (patch) | |
tree | 3fe9d75bdac809cb067d117e70b3de20aa84a029 | |
parent | 15eb263e54ac53ffc909e98faf102c000b96e503 (diff) | |
download | cmdtest-70a9839743280edf915c356c309991fba6d7790d.tar.gz |
Add --shell, --shell-arg settings
-rwxr-xr-x | yarn | 28 |
1 files changed, 25 insertions, 3 deletions
@@ -88,6 +88,18 @@ class YarnRunner(cliapp.Application): ['require-assumptions'], 'require ASSUMING to always pass') + self.settings.string( + ['shell'], + 'run IMPLEMENTS using SHELL', + metavar='SHELL', + default='/bin/sh') + + self.settings.string_list( + ['shell-arg'], + 'use ARG when running shell', + metavar='ARG', + default=['-xeu']) + def stdout(self, msg): self.output.write(msg) self.output.flush() @@ -436,10 +448,20 @@ class YarnRunner(cliapp.Application): for i, match in enumerate(m.groups('')): env['MATCH_%d' % (i+1)] = match - shell_script = '%s\n\n%s\n' % ( - shell_prelude, step.implementation.shell) + fd, shell_script = tempfile.mkstemp() + os.close(fd) + with open(shell_script, 'w') as f: + f.write(shell_prelude) + f.write(step.implementation.shell) + f.flush() + shell = self.settings['shell'] + shell_args = self.settings['shell-arg'] + logging.warning('shell: %r', shell) + logging.warning('shell_args: %r', shell_args) + logging.warning('shell_script: %r', shell_script) exit, stdout, stderr = cliapp.runcmd_unchecked( - ['sh', '-xeuc', shell_script], env=env) + [shell] + shell_args + [shell_script], env=env) + os.remove(shell_script) logging.debug('Exit code: %d' % exit) if stdout: |