mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
Cleanup pacman
rule
This commit is contained in:
parent
d41b1d48d2
commit
5f2b2433b1
@ -1,16 +1,5 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
from thefuck.utils import DEVNULL
|
from thefuck.utils import DEVNULL, which
|
||||||
|
|
||||||
|
|
||||||
def __command_available(command):
|
|
||||||
try:
|
|
||||||
subprocess.check_output([command], stderr=DEVNULL)
|
|
||||||
return True
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
# command exists but is not happy to be called without any argument
|
|
||||||
return True
|
|
||||||
except OSError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def __get_pkgfile(command):
|
def __get_pkgfile(command):
|
||||||
@ -33,11 +22,11 @@ def get_new_command(command, settings):
|
|||||||
return '{} -S {} && {}'.format(pacman, package, command.script)
|
return '{} -S {} && {}'.format(pacman, package, command.script)
|
||||||
|
|
||||||
|
|
||||||
if not __command_available('pkgfile'):
|
if not which('pkgfile'):
|
||||||
enabled_by_default = False
|
enabled_by_default = False
|
||||||
elif __command_available('yaourt'):
|
elif which('yaourt'):
|
||||||
pacman = 'yaourt'
|
pacman = 'yaourt'
|
||||||
elif __command_available('pacman'):
|
elif which('pacman'):
|
||||||
pacman = 'sudo pacman'
|
pacman = 'sudo pacman'
|
||||||
else:
|
else:
|
||||||
enabled_by_default = False
|
enabled_by_default = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user