1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-21 01:59:10 +00:00
thefuck/thefuck/rules/ln_no_hard_link.py
2016-03-02 17:57:53 +01:00

25 lines
544 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Suggest creating symbolic link if hard link is not allowed.
Example:
> ln barDir barLink
ln: barDir: hard link not allowed for directory
--> ln -s barDir barLink
"""
import re
from thefuck.utils import for_app
from thefuck.specific.sudo import sudo_support
@sudo_support
@for_app('ln')
def match(command):
return (command.stderr.endswith("hard link not allowed for directory") and
command.script.startswith("ln "))
@sudo_support
def get_new_command(command):
return re.sub(r'^ln ', 'ln -s ', command.script)