From 7fe4c309a764d31ae219f9c489e5823c2c45a405 Mon Sep 17 00:00:00 2001 From: Alice Jacka Date: Wed, 11 Sep 2024 23:49:33 +1000 Subject: [PATCH] Update chmod_x to work with non-relative paths Originally this rule only worked for scripts run with relative paths (eg `./funStuff.sh`) but that's not always what we need Imagine I have a file at `/home/alice/scripts/funStuff.sh` and my cwd is `/home/alice` I could run the script with `./scripts/funStuff.sh` or '~/scripts/funStuff.sh` or `/home/alice/scripts/funStuff.sh` --- thefuck/rules/chmod_x.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/thefuck/rules/chmod_x.py b/thefuck/rules/chmod_x.py index 09e685ee..794d7b76 100644 --- a/thefuck/rules/chmod_x.py +++ b/thefuck/rules/chmod_x.py @@ -3,10 +3,9 @@ from thefuck.shells import shell def match(command): - return (command.script.startswith('./') - and 'permission denied' in command.output.lower() - and os.path.exists(command.script_parts[0]) - and not os.access(command.script_parts[0], os.X_OK)) + return ('permission denied' in command.output.lower() + and os.path.exists(os.path.expanduser(command.script_parts[0])) + and not os.access(os.path.expanduser(command.script_parts[0]), os.X_OK)) def get_new_command(command):