falconindy / auracle

A flexible command line client for Arch Linux's User Repository
MIT License
235 stars 26 forks source link

"auracle outdated" exit code ambiguous #89

Closed karabaja4 closed 3 years ago

karabaja4 commented 3 years ago

Hello,

auracle has exit code 1 in both these situations:

No updates available:

~ >> auracle outdated
~ >> echo $?
1

Internet connection down:

~ >> auracle outdated
error: UNKNOWN: Could not resolve host: aur.archlinux.org
~ >> echo $?
1

This makes it hard to call auracle from scripts because it's impossible to differentiate between success/failure of fetching the number of upgradable packages without parsing stderr.

I would expect auracle to return 0 (success) if the connection to AUR is successfully established and no packages are upgradable, or return some error code other than 1 if there was a connection issue to differentiate this from a "no updates available" exit code.

Regards,

Igor

falconindy commented 3 years ago

IMO, it's perfectly fine that it's ambiguous. There's absolute consistency in a non-zero exit status indicating that no upgradable packages were able to be found, regardless of the reason. A zero exit status indicates with certainty that packages are available. This is a nice feature.

You should never need to query the AUR for upgrades such that you: a) have complex logic to retry failures based on an exit status, b) can't wait for the external condition to resolve itself some minutes/hours/days later. I do not want to commit to exit statuses as API.