summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorCatherine Devlin <catherine.devlin@gmail.com>2008-06-09 10:05:25 -0400
committerCatherine Devlin <catherine.devlin@gmail.com>2008-06-09 10:05:25 -0400
commitc28678c4603c189321a08a89148c69ac8b99676f (patch)
tree63343739e4704f9cc4a609e7d75241e97e67ec8c /cmd2.py
parentb3f9bb93b3c26b23d1b192aed3b5bc1e93b99066 (diff)
downloadcmd2-git-c28678c4603c189321a08a89148c69ac8b99676f.tar.gz
unifying pipe and redirect
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/cmd2.py b/cmd2.py
index d3af66b7..40867693 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -234,7 +234,7 @@ class Cmd(cmd.Cmd):
"""
command, args = self.extractCommand(line)
- statement = ' '.join([command, args])
+ statement = originalStatement = ' '.join([command, args])
if (not assumeComplete) and (command in self.multilineCommands):
statement = self.finishStatement(statement)
statekeeper = None
@@ -246,9 +246,11 @@ class Cmd(cmd.Cmd):
self.stdout = redirect.stdin
stop = cmd.Cmd.onecmd(self, statement)
statekeeper.restore()
- for result in redirect.communicate():
+ for result in redirect.communicate():
self.stdout.write(result or '')
- return stop # didn't record in history
+ if command not in self.excludeFromHistory:
+ self.history.append(originalStatement)
+ return stop
else:
statement, redirect, mode = self.parseRedirectors(statement)
if redirect == self._TO_PASTE_BUFFER:
@@ -273,7 +275,7 @@ class Cmd(cmd.Cmd):
stop = cmd.Cmd.onecmd(self, statement)
try:
if command not in self.excludeFromHistory:
- self.history.append(statement) # or should we append the unmodified statement?
+ self.history.append(originalStatement)
finally:
if statekeeper:
if redirect == self._TO_PASTE_BUFFER:
@@ -288,6 +290,7 @@ class Cmd(cmd.Cmd):
#import pdb; pdb.set_trace()
return bool(self.statementEndPattern.search(lines)) \
or lines[-3:] == 'EOF' \
+ or self.findPipe(lines)[1] \
or self.parseRedirectors(lines)[1]
def finishStatement(self, firstline):