mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 04:21:14 +00:00
#588: Stop using bashlex
This commit is contained in:
parent
03a828d586
commit
a778ea6203
2
setup.py
2
setup.py
@ -31,7 +31,7 @@ elif (3, 0) < version < (3, 3):
|
|||||||
|
|
||||||
VERSION = '3.12'
|
VERSION = '3.12'
|
||||||
|
|
||||||
install_requires = ['psutil', 'colorama', 'six', 'decorator', 'bashlex']
|
install_requires = ['psutil', 'colorama', 'six', 'decorator']
|
||||||
extras_require = {':python_version<"3.4"': ['pathlib2'],
|
extras_require = {':python_version<"3.4"': ['pathlib2'],
|
||||||
":sys_platform=='win32'": ['win_unicode_console']}
|
":sys_platform=='win32'": ['win_unicode_console']}
|
||||||
|
|
||||||
|
@ -58,11 +58,6 @@ class TestBash(object):
|
|||||||
assert list(shell.get_history()) == ['ls', 'rm']
|
assert list(shell.get_history()) == ['ls', 'rm']
|
||||||
|
|
||||||
def test_split_command(self, shell):
|
def test_split_command(self, shell):
|
||||||
command = 'git log $(git ls-files thefuck | grep python_command) -p'
|
command = 'git log -p'
|
||||||
command_parts = ['git', 'log', '$(git ls-files thefuck | grep python_command)', '-p']
|
command_parts = ['git', 'log', '-p']
|
||||||
assert shell.split_command(command) == command_parts
|
assert shell.split_command(command) == command_parts
|
||||||
|
|
||||||
# bashlex doesn't support parsing arithmetic expressions, so make sure
|
|
||||||
# shlex is used a fallback
|
|
||||||
# See https://github.com/idank/bashlex#limitations
|
|
||||||
assert shell.split_command('$((1 + 2))') == ['$((1', '+', '2))']
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import bashlex
|
|
||||||
import six
|
import six
|
||||||
from ..utils import memoize
|
from ..utils import memoize
|
||||||
from ..conf import settings
|
from ..conf import settings
|
||||||
@ -65,18 +64,9 @@ class Generic(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def split_command(self, command):
|
def split_command(self, command):
|
||||||
"""Split the command using shell-like syntax.
|
"""Split the command using shell-like syntax."""
|
||||||
|
|
||||||
If bashlex fails for some reason, fallback to shlex
|
|
||||||
See https://github.com/idank/bashlex#limitations
|
|
||||||
"""
|
|
||||||
encoded = self.encode_utf8(command)
|
encoded = self.encode_utf8(command)
|
||||||
|
|
||||||
try:
|
|
||||||
splitted = list(bashlex.split(encoded))
|
|
||||||
except Exception:
|
|
||||||
splitted = shlex.split(encoded)
|
splitted = shlex.split(encoded)
|
||||||
|
|
||||||
return self.decode_utf8(splitted)
|
return self.decode_utf8(splitted)
|
||||||
|
|
||||||
def encode_utf8(self, command):
|
def encode_utf8(self, command):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user