lilydjwg / nvchecker

New version checker for software releases
MIT License
425 stars 68 forks source link

Exit code #196

Closed pjvds closed 2 years ago

pjvds commented 3 years ago

It would be very helpful if nvchecker return a non succeeding exit code value when where are updates found. This would help me detecting new version by running a cron job that reports "failure".

lilydjwg commented 3 years ago

Reporting failure on updates seems weird. Instead you can run nvcmp to output the updates. cron should mail the output to you.

pjvds commented 3 years ago

I agree that it makes sense to use nvcmp to check for updates. It still would make sense for nvcmp to return an exit code reporting changes or not. Many tools do this, for example grep returns 0 if selected lines are found, and 1 if not found. If an error occurred the exit status is 2 or higher. Note that POSIX error handling code should check for 2 or greater.

lilydjwg commented 3 years ago

I'm considering adding a command line option (to nvcmp) to use exit code to indicate if there are updates. What do you think? Do you have a good option name for it?

trathborne commented 2 years ago

The grep 0/1 semantics sound fine to me: if nvcmp > nvcmp.out; then mail -s nvcmp operator@here < nvcmp.out; fi; rm nvcmp.out

... but it does make sense to make it optional in case somebody is using it in a set -e shell script and doesn't expect it to do this.

How about --exit-status ?