summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-04-23 20:16:55 -0600
committerkotfu <kotfu@kotfu.net>2018-04-23 20:16:55 -0600
commitb3d71457e951d9d382787cb82fdf77f32951337c (patch)
tree7e5284d2a7895a678fa73df3f2e695000ef7fdcd /cmd2
parent2534df2987a5aec226ce5bfd5b21f1d8f22ed3f2 (diff)
downloadcmd2-git-b3d71457e951d9d382787cb82fdf77f32951337c.tar.gz
Fix parsing of input redirection and appending output
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/parsing.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py
index c8110667..ec8e2e84 100644
--- a/cmd2/parsing.py
+++ b/cmd2/parsing.py
@@ -115,14 +115,16 @@ class CommandParser():
# check for input from file
inputFrom = None
try:
- if tokens[0] == '<':
- inputFrom = ' '.join(tokens[1:])
- tokens = []
- except IndexError:
+ input_pos = tokens.index('<')
+ inputFrom = ' '.join(tokens[input_pos+1:])
+ tokens = tokens[:input_pos]
+ except ValueError:
pass
# check for output redirect
+ output = None
+ outputTo = None
try:
output_pos = tokens.index('>')
output = '>'
@@ -130,13 +132,12 @@ class CommandParser():
# remove all the tokens after the output redirect
tokens = tokens[:output_pos]
except ValueError:
- output = None
- outputTo = None
+ pass
- # check for paste buffer
try:
output_pos = tokens.index('>>')
output = '>>'
+ outputTo = ' '.join(tokens[output_pos+1:])
# remove all tokens after the output redirect
tokens = tokens[:output_pos]
except ValueError: