Add no hard link support for ln

This commit is contained in:
lawrencebenson
2016-03-02 17:48:20 +01:00
parent 7ce4307c87
commit 48808f93ac
3 changed files with 70 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
"""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)