Compare commits
4 Commits
0.2.1
...
e2789d200b
Author | SHA1 | Date | |
---|---|---|---|
e2789d200b | |||
eddbe307c2 | |||
3e22f4ebbd | |||
cdc17a329b |
39
pman.sh
39
pman.sh
@@ -7,6 +7,24 @@ command=""
|
|||||||
more_arguments=false
|
more_arguments=false
|
||||||
su_needed=false
|
su_needed=false
|
||||||
|
|
||||||
|
# If sudo is needed and necessary (and installed), prepend it, if not installed throw error
|
||||||
|
check_sudo() {
|
||||||
|
if [ "$su_needed" = "true" ] && [ "$UID" != 0 ]; then
|
||||||
|
if command -v "sudo" &>/dev/null; then
|
||||||
|
command="sudo $command"
|
||||||
|
else
|
||||||
|
echo "sudo command needed but not found" > /dev/stderr
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute the command
|
||||||
|
execute_command() {
|
||||||
|
check_sudo
|
||||||
|
$command $command_args "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
# Check if yay (aur)
|
# Check if yay (aur)
|
||||||
if [ "$command_args" = "yay" ] || [ "$command_args" = "aur" ]; then
|
if [ "$command_args" = "yay" ] || [ "$command_args" = "aur" ]; then
|
||||||
command="yay"
|
command="yay"
|
||||||
@@ -30,7 +48,15 @@ fi
|
|||||||
if [ "$command_args" = "search" ]; then
|
if [ "$command_args" = "search" ]; then
|
||||||
command_args="-Ss"
|
command_args="-Ss"
|
||||||
elif [ "$command_args" = "provides" ]; then
|
elif [ "$command_args" = "provides" ]; then
|
||||||
|
# Update the cache
|
||||||
|
su_needed=true
|
||||||
|
command_args="-Fy"
|
||||||
|
execute_command "${@}"
|
||||||
|
|
||||||
|
su_needed=false
|
||||||
command_args="-F"
|
command_args="-F"
|
||||||
|
elif [ "$command_args" = "installed" ]; then
|
||||||
|
command_args="-Q"
|
||||||
elif [ "$command_args" = "install" ]; then
|
elif [ "$command_args" = "install" ]; then
|
||||||
command_args="-S"
|
command_args="-S"
|
||||||
if [ "$command" = "pacman" ]; then
|
if [ "$command" = "pacman" ]; then
|
||||||
@@ -68,6 +94,7 @@ elif [ "$more_arguments" = "true" ]; then
|
|||||||
echo " aur (yay) - yay | same as \"yay\""
|
echo " aur (yay) - yay | same as \"yay\""
|
||||||
echo " search - pacman -Ss | search packages"
|
echo " search - pacman -Ss | search packages"
|
||||||
echo " provides - pacman -F | list packages that provide file"
|
echo " provides - pacman -F | list packages that provide file"
|
||||||
|
echo " installed - pacman -Q | list installed packages"
|
||||||
echo " install - pacman -S | install packages"
|
echo " install - pacman -S | install packages"
|
||||||
echo " update - pacman -Sy | updates the repositories"
|
echo " update - pacman -Sy | updates the repositories"
|
||||||
echo " upgradable - pacman -Qu | list available upgrades"
|
echo " upgradable - pacman -Qu | list available upgrades"
|
||||||
@@ -78,14 +105,4 @@ elif [ "$more_arguments" = "true" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If sudo is needed and necessary (and installed), prepend it, if not installed throw error
|
execute_command "${@}"
|
||||||
if [ "$su_needed" = "true" ] && [ "$UID" != 0 ]; then
|
|
||||||
if command -v "sudo" &>/dev/null; then
|
|
||||||
sudo $command $command_args "${@}"
|
|
||||||
else
|
|
||||||
echo "sudo command needed but not found" > /dev/stderr
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
$command $command_args "${@}"
|
|
||||||
fi
|
|
||||||
|
Reference in New Issue
Block a user