mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 14:48:49 +00:00
Merge 06386601d927c00bd40d1f92ded20a88b36e1197 into b55464b2ea46bf16eb964d704e2e2fbae0ab96dc
This commit is contained in:
commit
fe67d1529c
@ -12,7 +12,7 @@ import os
|
||||
import shlex
|
||||
import six
|
||||
from .utils import DEVNULL, memoize, cache
|
||||
|
||||
import sys
|
||||
|
||||
class Generic(object):
|
||||
|
||||
@ -49,7 +49,10 @@ class Generic(object):
|
||||
history_file_name = self._get_history_file_name()
|
||||
if os.path.isfile(history_file_name):
|
||||
with open(history_file_name, 'a') as history:
|
||||
history.write(self._get_history_line(command_script))
|
||||
if sys.version_info >= (3, 0):
|
||||
history.write(self._get_history_line(command_script))
|
||||
else:
|
||||
history.write(self._get_history_line(command_script).encode("utf-8"))
|
||||
|
||||
def _script_from_history(self, line):
|
||||
"""Returns prepared history line.
|
||||
@ -79,7 +82,7 @@ class Generic(object):
|
||||
|
||||
def split_command(self, command):
|
||||
"""Split the command using shell-like syntax."""
|
||||
return shlex.split(command)
|
||||
return shlex.split(command.encode("utf-8"))
|
||||
|
||||
def quote(self, s):
|
||||
"""Return a shell-escaped version of the string s."""
|
||||
|
@ -31,7 +31,7 @@ class Command(object):
|
||||
try:
|
||||
self._script_parts = shells.split_command(self.script)
|
||||
except Exception:
|
||||
logs.debug("Can't split command script {} because:\n {}".format(
|
||||
logs.debug(u"Can't split command script {} because:\n {}".format(
|
||||
self, sys.exc_info()))
|
||||
self._script_parts = None
|
||||
return self._script_parts
|
||||
@ -44,7 +44,7 @@ class Command(object):
|
||||
return False
|
||||
|
||||
def __repr__(self):
|
||||
return 'Command(script={}, stdout={}, stderr={})'.format(
|
||||
return u'Command(script={}, stdout={}, stderr={})'.format(
|
||||
self.script, self.stdout, self.stderr)
|
||||
|
||||
def update(self, **kwargs):
|
||||
@ -279,4 +279,4 @@ class CorrectedCommand(object):
|
||||
if self.side_effect:
|
||||
compatibility_call(self.side_effect, old_cmd, self.script)
|
||||
shells.put_to_history(self.script)
|
||||
print(self.script)
|
||||
print(self.script.encode("utf-8"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user