mirror of
https://github.com/nvbn/thefuck.git
synced 2025-11-02 16:12:08 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a65f90813b | ||
|
|
a778ea6203 |
4
setup.py
4
setup.py
@@ -29,9 +29,9 @@ elif (3, 0) < version < (3, 3):
|
||||
' ({}.{} detected).'.format(*version))
|
||||
sys.exit(-1)
|
||||
|
||||
VERSION = '3.12'
|
||||
VERSION = '3.13'
|
||||
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user