Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special exit status when sudo is required #394

Closed
AladW opened this issue Feb 21, 2016 · 3 comments
Closed

Special exit status when sudo is required #394

AladW opened this issue Feb 21, 2016 · 3 comments

Comments

@AladW
Copy link
Contributor

AladW commented Feb 21, 2016

If an automatic sudo prompt isn't possible (#334), then aura should at least have a special exit code, rather than 1, when sudo is required. This way, you don't need to grep stderr or check for used arguments in bash wrappers.

@fosskers
Copy link
Owner

What's your use case?

@AladW
Copy link
Contributor Author

AladW commented Feb 21, 2016

Right now there's an ugly wrapper for people who expect automatic elevation from aura (as in pacaur and other helpers), from the ArchWiki:

function a(){
    AURA="$(aura "$@")"

    if echo "$AURA" | grep -q '^aura >>= .*You have to use `.*sudo.*` for that.*$'
    then
        sudo aura "$@"
    else
        echo "$AURA"
    fi
}

With an exit code of say 2, this could be reduced to:

function a() {
  aura "$@"
  (( $? = 2 )) && sudo aura "$@"
}

@AladW
Copy link
Contributor Author

AladW commented Mar 10, 2016

Looking at this again, grepping stdout really isn't reliable, unless you set LC_MESSAGES=C. See rmarquis/pacaur#267

@fosskers fosskers added this to the Aura 1.4 milestone Mar 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants