redhat-cip / edeploy

Linux systems provisioning and updating made easy
Apache License 2.0
92 stars 38 forks source link

configure scripts cannot use pipe characters inside run() commands #223

Open gerhardqux opened 9 years ago

gerhardqux commented 9 years ago

The run() implementation fails on pipe characters as of: https://github.com/enovance/edeploy/commit/a37894a81cdcd0114a00417b95f28199792abbc3

[root@(none) /]# ./test
1: 0 qux
+ echo qux | sort | sort
sort: fflush failed: standard output: Broken pipe
sort: write error
[root@(none) /]# cat test
#!/usr/bin/env python

import commands
import sys

def run(cmd):
    sys.stderr.write('+ ' + cmd + '\n')
    status, output = commands.getstatusoutput(cmd + ' </dev/null')
    sys.stderr.write(output + '\n')
    if status != 0:
        sys.stderr.write("Command '%s' failed\n" % cmd)
        sys.stderr.write("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
        sys.stderr.write("!!! Configure script exited prematurely !!!\n")
        sys.stderr.write("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
        sys.exit(status)

testcmd='echo qux | sort | sort'

status, output = commands.getstatusoutput(testcmd)
sys.stderr.write("1: %d %s\n" % (status, output))

run(testcmd)

#run('echo bar | sort | sort')
#run('ls /sys/block/ | grep "^sd" >/after')