mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	Added side_effect to support destroying system
This commit is contained in:
		| @@ -1,3 +1,5 @@ | |||||||
|  | import sys | ||||||
|  | from warnings import warn | ||||||
| from thefuck.specific.sudo import sudo_support | from thefuck.specific.sudo import sudo_support | ||||||
|  |  | ||||||
| enabled_by_default = False | enabled_by_default = False | ||||||
| @@ -9,6 +11,16 @@ def match(command): | |||||||
|             and {'rm', '/'}.issubset(command.script_parts)) |             and {'rm', '/'}.issubset(command.script_parts)) | ||||||
|  |  | ||||||
|  |  | ||||||
| @sudo_support |  | ||||||
| def get_new_command(command): | def get_new_command(command): | ||||||
|     return u'echo "I\'m saving your life. Thank me later"' |     return '{} {} {}'.format(command.script_parts[0], '-rf', ' '.join(command.script_parts[1:])) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def side_effect(old_cmd, command): | ||||||
|  |     warn("DANGER!!! THIS MAY DESTROY YOUR SYSTEM! ARE YOU SURE? (y/N): ") | ||||||
|  |     try: | ||||||
|  |         input = raw_input | ||||||
|  |     except NameError: | ||||||
|  |         pass | ||||||
|  |     reply = input().strip().lower()  # raw_input should be used in Python 2 | ||||||
|  |     if not reply or reply[0] != "y": | ||||||
|  |         sys.exit(0) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user