# HG changeset patch # User catherine@localhost # Date 1213020325 14400 # Node ID dccf27f52f519ed209cb26e71a41c0f8f0ba73b4 # Parent 8926b72d828e1e54133106edd5604a468456ee98 unifying pipe and redirect diff -r 8926b72d828e -r dccf27f52f51 cmd2.py --- a/cmd2.py Fri Jun 06 16:51:09 2008 -0400 +++ b/cmd2.py Mon Jun 09 10:05:25 2008 -0400 @@ -234,7 +234,7 @@ """ 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 @@ 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 @@ 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 @@ #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):