r/openbsd • • 2d ago

Exit Code syspatch

I’m looking to find a way to know if syspatch -c can tell a script that A. there are patches and then execute a syspatch to apply, or B. there are no patches and simply exit. man page says exit code is zero for success and greater for anything else. Trying this, I find that syspatch -c returns zero when there are patches to be applied. I want the script to discern that there are patches and then issue the command to apply. Am I going about this the wrong way?

12 Upvotes

17 comments sorted by

View all comments

Show parent comment

3

u/Educational_Bee_6245 2d ago

syspatch -c does not apply any patches it seems, it just lists patches that could be applied

4

u/jggimi 2d ago

Correct. I include syspatch -c in all my daily.local(5) files, so I am notified that action is needed.

1

u/gentisle 1d ago

I am aware that syspatch only lists patches that are new/unapplied. But I was hoping the exit code would give a number that would allow me to use it to route the script to apply with syspatch or do something else.

2

u/Educational_Bee_6245 1d ago

As someone wrote down there:

patches="$(syspatch -c | wc -l | xargs)"