From f05a55a0af30f642a667f2eafbefc81477c010f0 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Sun, 6 Jun 2021 05:05:10 +0300 Subject: [PATCH] Support quoting for command arguments I've encountered a problem when trying to use a passphrase with spaces in `/olm import`. The arguments were just broken by spaces. shlex has more advanced splitting which allows taking multi-word arguments in quotes. --- matrix/commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/matrix/commands.py b/matrix/commands.py index 53faf74..7f8ce0e 100644 --- a/matrix/commands.py +++ b/matrix/commands.py @@ -19,6 +19,7 @@ from __future__ import unicode_literals import argparse import os import re +import shlex from builtins import str from future.moves.itertools import zip_longest from collections import defaultdict @@ -60,7 +61,7 @@ class WeechatCommandParser(object): @staticmethod def _run_parser(parser, args): try: - parsed_args = parser.parse_args(args.split()) + parsed_args = parser.parse_args(shlex.split(args)) return parsed_args except ParseError: return None