1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-21 10:08:59 +00:00
thefuck/thefuck/rules/has_exists_script.py
ilovezfs c4007f3456 Delete NULL bytes from command.script_parts[0]
The byte sequence in command.script_parts[0] can contain one or more
'\x00' which will cause os.stat(path) to throw this error:

        TypeError: must be encoded string without NULL bytes, not str
2015-11-29 00:19:58 -08:00

15 lines
342 B
Python

import os
from thefuck.specific.sudo import sudo_support
@sudo_support
def match(command):
return command.script_parts and os.path.exists(
command.script_parts[0].translate(None, '\x00')) \
and 'command not found' in command.stderr
@sudo_support
def get_new_command(command):
return u'./{}'.format(command.script)