2
def __init__(self, args, redirects):
4
self.redirects = list(redirects)
7
return 'Command(%r, %r)' % (self.args, self.redirects)
9
def __cmp__(self, other):
10
if not isinstance(other, Command):
13
return cmp((self.args, self.redirects),
14
(other.args, other.redirects))
16
def toShell(self, file):
20
elif '"' not in arg and '$' not in arg:
23
raise NotImplementedError,'Unable to quote %r' % arg
26
# For debugging / validation.
28
dequoted = list(ShUtil.ShLexer(quoted).lex())
30
raise NotImplementedError,'Unable to quote %r' % arg
32
for r in self.redirects:
34
print >>file, "%s '%s'" % (r[0][0], r[1]),
36
print >>file, "%s%s '%s'" % (r[0][1], r[0][0], r[1]),
39
def __init__(self, commands, negate=False, pipe_err=False):
40
self.commands = commands
42
self.pipe_err = pipe_err
45
return 'Pipeline(%r, %r, %r)' % (self.commands, self.negate,
48
def __cmp__(self, other):
49
if not isinstance(other, Pipeline):
52
return cmp((self.commands, self.negate, self.pipe_err),
53
(other.commands, other.negate, self.pipe_err))
55
def toShell(self, file, pipefail=False):
56
if pipefail != self.pipe_err:
57
raise ValueError,'Inconsistent "pipefail" attribute!'
60
for cmd in self.commands:
62
if cmd is not self.commands[-1]:
66
def __init__(self, lhs, op, rhs):
67
assert op in (';', '&', '||', '&&')
73
return 'Seq(%r, %r, %r)' % (self.lhs, self.op, self.rhs)
75
def __cmp__(self, other):
76
if not isinstance(other, Seq):
79
return cmp((self.lhs, self.op, self.rhs),
80
(other.lhs, other.op, other.rhs))
82
def toShell(self, file, pipefail=False):
83
self.lhs.toShell(file, pipefail)
84
print >>file, ' %s\n' % self.op
85
self.rhs.toShell(file, pipefail)