1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-22 12:58:33 +00:00

bash: use generic shell's UTF-8 methods

This commit is contained in:
Joseph Frazier 2016-11-23 08:12:01 -05:00
parent 385746850e
commit 4ae32cf4ee

View File

@ -1,6 +1,5 @@
import os import os
import bashlex import bashlex
import six
from ..conf import settings from ..conf import settings
from ..utils import memoize from ..utils import memoize
from .generic import Generic from .generic import Generic
@ -49,17 +48,11 @@ class Bash(Generic):
return 'eval $(thefuck --alias)', config return 'eval $(thefuck --alias)', config
def split_command(self, command): def split_command(self, command):
if six.PY2: generic = Generic()
command = command.encode('utf8')
# If bashlex fails for some reason, fallback to shlex # If bashlex fails for some reason, fallback to shlex
# See https://github.com/idank/bashlex#limitations # See https://github.com/idank/bashlex#limitations
try: try:
command_parts = list(bashlex.split(command)) return generic.decode_utf8(list(bashlex.split(generic.encode_utf8(command))))
except: except:
return Generic().split_command(command) return generic.split_command(command)
if six.PY2:
return [s.decode('utf8') for s in command_parts]
else:
return command_parts