diff options
author | catherine devlin <catherine.devlin@gmail.com> | 2011-08-25 15:24:56 -0400 |
---|---|---|
committer | catherine devlin <catherine.devlin@gmail.com> | 2011-08-25 15:24:56 -0400 |
commit | e05f7527cfd9314ef3aa1c6203d9e4c033f81ae1 (patch) | |
tree | 07c26f5f35acb0a19d0354402cd729f0619730e9 /cmd2.py | |
parent | bf78cb82f0f7119058d94330a69455f3cd9980c0 (diff) | |
download | cmd2-hg-e05f7527cfd9314ef3aa1c6203d9e4c033f81ae1.tar.gz |
custom double-redirector fixed
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -379,6 +379,7 @@ class Cmd(cmd.Cmd): debug = False locals_in_py = True kept_state = None + redirector = '>' # for sending output to file settable = stubbornDict(''' prompt colors Colorized output (*nix only) @@ -665,7 +666,10 @@ class Cmd(cmd.Cmd): - args: if "quoted strings /* seem to " start comments? - command: what ''' - outputParser = (pyparsing.Literal('>>') | (pyparsing.WordStart() + '>') | pyparsing.Regex('[^=]>'))('output') + #outputParser = (pyparsing.Literal('>>') | (pyparsing.WordStart() + '>') | pyparsing.Regex('[^=]>'))('output') + outputParser = (pyparsing.Literal(self.redirector *2) | \ + (pyparsing.WordStart() + self.redirector) | \ + pyparsing.Regex('[^=]' + self.redirector))('output') terminatorParser = pyparsing.Or([(hasattr(t, 'parseString') and t) or pyparsing.Literal(t) for t in self.terminators])('terminator') stringEnd = pyparsing.stringEnd ^ '\nEOF' @@ -815,7 +819,7 @@ class Cmd(cmd.Cmd): self.kept_sys = Statekeeper(sys, ('stdout',)) if statement.parsed.outputTo: mode = 'w' - if statement.parsed.output == '>>': + if statement.parsed.output == 2 * self.redirector: mode = 'a' sys.stdout = self.stdout = open(os.path.expanduser(statement.parsed.outputTo), mode) else: |