1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-12 07:59:01 +00:00

Merge pull request #332 from mcarton/331

#331 Fix bug with empty commands
This commit is contained in:
Vladimir Iakovlev 2015-08-11 16:04:00 +03:00
commit 0ad70a1edc
2 changed files with 9 additions and 1 deletions

View File

@ -35,6 +35,8 @@ class TestGetCommand(object):
env={}) env={})
@pytest.mark.parametrize('args, result', [ @pytest.mark.parametrize('args, result', [
(['thefuck', ''], None),
(['thefuck', '', ''], None),
(['thefuck', 'ls', '-la'], 'ls -la'), (['thefuck', 'ls', '-la'], 'ls -la'),
(['thefuck', 'ls'], 'ls')]) (['thefuck', 'ls'], 'ls')])
def test_get_command_script(self, args, result): def test_get_command_script(self, args, result):

View File

@ -27,7 +27,7 @@ def setup_user_dir():
def wait_output(settings, popen): def wait_output(settings, popen):
"""Returns `True` if we can get output of the command in the """Returns `True` if we can get output of the command in the
`wait_command` time. `settings.wait_command` time.
Command will be killed if it wasn't finished in the time. Command will be killed if it wasn't finished in the time.
@ -50,6 +50,7 @@ def get_command(settings, args):
else: else:
script = ' '.join(args[1:]) script = ' '.join(args[1:])
script = script.strip()
if not script: if not script:
return return
@ -91,6 +92,11 @@ def fix_command():
logs.debug(u'Run with settings: {}'.format(pformat(settings)), settings) logs.debug(u'Run with settings: {}'.format(pformat(settings)), settings)
command = get_command(settings, sys.argv) command = get_command(settings, sys.argv)
if not command:
logs.debug('Empty command, nothing to do', settings)
return
corrected_commands = get_corrected_commands(command, user_dir, settings) corrected_commands = get_corrected_commands(command, user_dir, settings)
selected_command = select_command(corrected_commands, settings) selected_command = select_command(corrected_commands, settings)
if selected_command: if selected_command: