From cb31a1f7d08776b5a9e42bc944b2e12a23c1613e Mon Sep 17 00:00:00 2001 From: Sudeep Juvekar Date: Mon, 20 Apr 2015 10:49:39 -0400 Subject: [PATCH] A special case for 'Permission denied' error msg when trying to execute a python scripy. The script does not have execute permission and/or does not start with !#/usr/... In that case, pre-pend the command with 'python' keyword. Change-Id: Idf73ee9cf0a523f51c78672188a457b2fcedc1e6 --- thefuck/rules/python_command.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thefuck/rules/python_command.py b/thefuck/rules/python_command.py index 99169de..3fc4782 100644 --- a/thefuck/rules/python_command.py +++ b/thefuck/rules/python_command.py @@ -4,7 +4,8 @@ def match(command, settings): toks = command.script.split() - return (toks[0].endswith('.py') + return (len(toks) > 0 + and toks[0].endswith('.py') and ('Permission denied' in command.stderr or 'command not found' in command.stderr))