Compare commits

..

No commits in common. "e2789d200b4587f79f51234f28ed276ac2e2ab52" and "cdc17a329b2e6b557e858ff393f9b264e673ffb5" have entirely different histories.

36
pman.sh
View File

@ -7,24 +7,6 @@ command=""
more_arguments=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)
if [ "$command_args" = "yay" ] || [ "$command_args" = "aur" ]; then
command="yay"
@ -48,12 +30,6 @@ fi
if [ "$command_args" = "search" ]; then
command_args="-Ss"
elif [ "$command_args" = "provides" ]; then
# Update the cache
su_needed=true
command_args="-Fy"
execute_command "${@}"
su_needed=false
command_args="-F"
elif [ "$command_args" = "installed" ]; then
command_args="-Q"
@ -105,4 +81,14 @@ elif [ "$more_arguments" = "true" ]; then
exit 1
fi
execute_command "${@}"
# If sudo is needed and necessary (and installed), prepend it, if not installed throw error
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