On Sun, 2023-07-02 at 15:51 +0200, Marc Espie wrote: > Use-case: some people want to branch automated installs based on > whether > pkg_add -u (or some other variation) actually did something. > > As usual we ignore quirks. This adds a flag (-DSYSPATCH_LIKE) > which governs the behavior. Code is fairly self-explanatory. > > I had no better idea for the flag name so far, suggestions welcome. > > > +sub exit_code($self, $state) > +{ > + my $rc = $self->SUPER::exit_code($state); > + if ($rc == 0 && $state->defines("SYSPATCH_LIKE")) { > + if (!$state->{did_something}) { > + $rc = 2; > + } > + } > + return $rc; > +} > > sub new_state($self, $cmd) > { >
if I read well, the exit code is 2 when something pkg_add changed something? syspatch exits with 0 when installing an update, 1 if it fails, 2 if didn't do anything Could it be possible to keep it consistent? pkg_add upgrading/installing a package should exit with 0, so it doesn't break current scripts, and this is what you would expect. Although, it could exit with 2 if you asked to install a package that already exist. And 1 if pkg_add failed.