diff options
author | Adam Spragg <adam@spra.gg> | 2022-05-23 15:29:11 +0100 |
---|---|---|
committer | Adam Spragg <adam@spra.gg> | 2022-05-24 10:12:33 +0100 |
commit | a0902fe51010645f779e4d02cd46f35e488b8bd2 (patch) | |
tree | c741aea22bae668fee418b8ac0938bdbc96675c6 /src/metastore.c | |
parent | 7c0520451b071e77b4c432ed89fc7559b8c58138 (diff) |
Return non-zero exit status if "compare" finds differences
This makes `metastore` more useful in scripts, just to check if it found
anything, in the same way as `diff` and `grep`.
Note that POSIX requires that EXIT_SUCCESS is 0, and EXIT_FAILURE is 1,
so I've defined EXIT_DIFFERENCES as 2 which, while different from the
values `diff` and `grep` use (1 for finding something, 2 for errors),
maintains a certain amount of backwards compatibility with previous
versions of metastore.
Diffstat (limited to 'src/metastore.c')
-rw-r--r-- | src/metastore.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/metastore.c b/src/metastore.c index 2f6d9bc..fb70834 100644 --- a/src/metastore.c +++ b/src/metastore.c @@ -572,7 +572,8 @@ main(int argc, char **argv) switch (action) { case ACTION_DIFF: - mentries_compare(real, stored, compare_print, &settings); + if (mentries_compare(real, stored, compare_print, &settings) > 0) + exit(EXIT_DIFFERENCES); break; case ACTION_SAVE: mentries_tofile(real, settings.metafile, settings.format); |