From 781ae4b99cbb3c1137697ac31100e43bbae4b4ea Mon Sep 17 00:00:00 2001 From: Ian Adam Naval Date: Thu, 26 Feb 2015 18:19:12 -0500 Subject: [PATCH] Moved shlex import to the raw command module Makes much more sense to do the parsing at that point. --- psh/console.py | 3 +-- psh/raw_commands.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/psh/console.py b/psh/console.py index cf649d7..491440f 100644 --- a/psh/console.py +++ b/psh/console.py @@ -2,7 +2,6 @@ import atexit import code import os import readline -import shlex from psh.commands import registered_cmds @@ -23,7 +22,7 @@ def parse_cmd(potential_cmd): if args: args = args[1:] if cmd_name not in registered_cmds: - return "RawCommand({})".format(shlex.split(potential_cmd)) + return "RawCommand('{}')".format(potential_cmd) else: cls = registered_cmds[cmd_name].__name__ return "{0}({1})".format(cls, str(args)) diff --git a/psh/raw_commands.py b/psh/raw_commands.py index 6777bc1..1d61444 100644 --- a/psh/raw_commands.py +++ b/psh/raw_commands.py @@ -1,3 +1,5 @@ +import shlex + from psh.formatters import Printer from psh.commands import BaseCommand @@ -15,7 +17,7 @@ class RawCommand(BaseCommand): input_generator = self.get_input_generator() import subprocess try: - p = subprocess.Popen(self.cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) + p = subprocess.Popen(shlex.split(self.cmd), stdin=subprocess.PIPE, stdout=subprocess.PIPE) def make_output_generator(): input_str = b"" for line in input_generator: