mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +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'
|
||||
|
||||
install_requires = ['psutil', 'colorama', 'six', 'decorator', 'bashlex']
|
||||
install_requires = ['psutil', 'colorama', 'six', 'decorator']
|
||||
extras_require = {':python_version<"3.4"': ['pathlib2'],
|
||||
":sys_platform=='win32'": ['win_unicode_console']}
|
||||
|
||||
|
@ -58,11 +58,6 @@ class TestBash(object):
|
||||
assert list(shell.get_history()) == ['ls', 'rm']
|
||||
|
||||
def test_split_command(self, shell):
|
||||
command = 'git log $(git ls-files thefuck | grep python_command) -p'
|
||||
command_parts = ['git', 'log', '$(git ls-files thefuck | grep python_command)', '-p']
|
||||
command = 'git log -p'
|
||||
command_parts = ['git', 'log', '-p']
|
||||
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 os
|
||||
import shlex
|
||||
import bashlex
|
||||
import six
|
||||
from ..utils import memoize
|
||||
from ..conf import settings
|
||||
@ -65,18 +64,9 @@ class Generic(object):
|
||||
return
|
||||
|
||||
def split_command(self, command):
|
||||
"""Split the command using shell-like syntax.
|
||||
|
||||
If bashlex fails for some reason, fallback to shlex
|
||||
See https://github.com/idank/bashlex#limitations
|
||||
"""
|
||||
"""Split the command using shell-like syntax."""
|
||||
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)
|
||||
|
||||
def encode_utf8(self, command):
|
||||
|
Loading…
x
Reference in New Issue
Block a user