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 | 4074386806bcdc17980abe5526c841b5302ffb31 (patch) | |
| tree | 07c26f5f35acb0a19d0354402cd729f0619730e9 /cmd2.py | |
| parent | b9d2610cad9a018870663628514e743d901fe753 (diff) | |
| download | cmd2-git-4074386806bcdc17980abe5526c841b5302ffb31.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: |
