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

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`
This commit is contained in:
Alice Jacka 2024-09-11 23:49:33 +10:00 committed by GitHub
parent c7e7e1d884
commit 7fe4c309a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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):