From 9dd7d8a58ba7d41cbdf9fb422e4384167496b94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alban=20F=C3=A9ron?= Date: Sat, 24 Aug 2019 17:40:48 +0200 Subject: [PATCH] Properly recompose/split command line Fixes #161 --- supysonic/cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/supysonic/cli.py b/supysonic/cli.py index 69b0d58..a75733d 100755 --- a/supysonic/cli.py +++ b/supysonic/cli.py @@ -10,6 +10,8 @@ import argparse import cmd import getpass +import pipes # replace by shlex once Python 2.7 supprt is dropped +import shlex import sys import time @@ -55,7 +57,7 @@ class SupysonicCLI(cmd.Cmd): def _make_do(self, command): def method(obj, line): try: - args = getattr(obj, command + "_parser").parse_args(line.split()) + args = getattr(obj, command + "_parser").parse_args(shlex.split(line)) except RuntimeError as e: self.write_error_line(str(e)) return @@ -405,7 +407,7 @@ def main(): cli = SupysonicCLI(config) if len(sys.argv) > 1: - cli.onecmd(" ".join(sys.argv[1:])) + cli.onecmd(" ".join(pipes.quote(arg) for arg in sys.argv[1:])) else: cli.cmdloop()