[pacman-dev] [PATCH] pacscripts: Don't ask if sudo is installed; just check for it and inform the user

Jason St. John jstjohn at purdue.edu
Fri Nov 15 20:37:57 EST 2013


On Fri, Nov 15, 2013 at 6:32 AM, Allan McRae <allan at archlinux.org> wrote:
> On 15/11/13 16:01, Jason St. John wrote:
>> Have pacscripts check if "sudo" is installed when the sudo binary cannot
>> be found, and remove the "Is sudo installed?" question.
>>
>> Signed-off-by: Jason St. John <jstjohn at purdue.edu>
>> ---
>> It doesn't make sense to force the user to run "pacman -Qi sudo", when we can
>> easily check if sudo is installed automatically and inform the user.
>>
>>
>>  contrib/pacscripts.sh.in | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/contrib/pacscripts.sh.in b/contrib/pacscripts.sh.in
>> index 8453f9c..7ab7b0d 100644
>> --- a/contrib/pacscripts.sh.in
>> +++ b/contrib/pacscripts.sh.in
>> @@ -71,8 +71,12 @@ spacman() {
>>               pacman "$@"
>>       else
>>               if ! type -p sudo; then
>> -                     error "Cannot find the sudo binary! Is sudo installed?"
>> -                     error "Otherwise, try to run the program as root"
>> +                     error "Cannot find the sudo binary!"
>> +                     if [ "$(pacman -Qq sudo)" != "sudo" ]; then
>> +                             error "\"sudo\" is not installed. Either install it or run the program as root."
>> +                     else
>> +                             error "However, \"sudo\" appears to be installed. Try running the program as root."
>
> That else is awful...
>
> How about just:
>
> "${progname} requires root privileges.  Either install sudo or run as root."
>
> or similar.
>
> A
>> +                     fi
>>                       exit 1
>>               else
>>                       sudo pacman "$@"
>>
>
>

That works for me. I thought the original error messages weren't that
great to begin with, but I figured I'd try to not lose any
functionality (if you even want to call it that). I'll be resubmitting
this soon.

Jason


More information about the pacman-dev mailing list