summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorcatherine devlin <catherine.devlin@gmail.com>2011-08-25 15:24:56 -0400
committercatherine devlin <catherine.devlin@gmail.com>2011-08-25 15:24:56 -0400
commite05f7527cfd9314ef3aa1c6203d9e4c033f81ae1 (patch)
tree07c26f5f35acb0a19d0354402cd729f0619730e9 /cmd2.py
parentbf78cb82f0f7119058d94330a69455f3cd9980c0 (diff)
downloadcmd2-hg-e05f7527cfd9314ef3aa1c6203d9e4c033f81ae1.tar.gz
custom double-redirector fixed
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd2.py b/cmd2.py
index 332d9b3..e0ebca3 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -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: