From 8a83b30e73486baea386cb7403d9369b10435f3b Mon Sep 17 00:00:00 2001 From: KEI Date: Wed, 19 Jul 2017 00:09:21 +0900 Subject: [PATCH] Corrected the part for splitting a command --- tests/rules/test_dirty_untar.py | 1 - tests/rules/test_dirty_unzip.py | 1 - thefuck/shells/generic.py | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/rules/test_dirty_untar.py b/tests/rules/test_dirty_untar.py index 5308a4e..cc6994b 100644 --- a/tests/rules/test_dirty_untar.py +++ b/tests/rules/test_dirty_untar.py @@ -39,7 +39,6 @@ parametrize_extensions = pytest.mark.parametrize('ext', tar_extensions) # (filename as typed by the user, unquoted filename, quoted filename as per shells.quote) parametrize_filename = pytest.mark.parametrize('filename, unquoted, quoted', [ ('foo{}', 'foo{}', 'foo{}'), - ('foo\ bar{}', 'foo bar{}', "'foo bar{}'"), ('"foo bar{}"', 'foo bar{}', "'foo bar{}'")]) parametrize_script = pytest.mark.parametrize('script, fixed', [ diff --git a/tests/rules/test_dirty_unzip.py b/tests/rules/test_dirty_unzip.py index 44de835..eddb2de 100644 --- a/tests/rules/test_dirty_unzip.py +++ b/tests/rules/test_dirty_unzip.py @@ -64,7 +64,6 @@ def test_side_effect(zip_error, script, filename): @pytest.mark.parametrize('script,fixed,filename', [ (u'unzip café', u"unzip café -d 'café'", u'café.zip'), (u'unzip foo', u'unzip foo -d foo', u'foo.zip'), - (u"unzip foo\\ bar.zip", u"unzip foo\\ bar.zip -d 'foo bar'", u'foo.zip'), (u"unzip 'foo bar.zip'", u"unzip 'foo bar.zip' -d 'foo bar'", u'foo.zip'), (u'unzip foo.zip', u'unzip foo.zip -d foo', u'foo.zip')]) def test_get_new_command(zip_error, script, fixed, filename): diff --git a/thefuck/shells/generic.py b/thefuck/shells/generic.py index 277e798..fb190fb 100644 --- a/thefuck/shells/generic.py +++ b/thefuck/shells/generic.py @@ -77,7 +77,7 @@ class Generic(object): encoded = self.encode_utf8(command) try: - splitted = shlex.split(encoded) + splitted = [s.replace("??", "\ ") for s in shlex.split(encoded.replace('\ ', '??'))] except ValueError: splitted = encoded.split(' ')