diff --git a/doc/mkdwarfs.md b/doc/mkdwarfs.md index 6ed7ef8a..244de0d0 100644 --- a/doc/mkdwarfs.md +++ b/doc/mkdwarfs.md @@ -419,6 +419,13 @@ Most other options are concerned with compression tuning: Show full usage with all options, including defaults, compression level detail and supported compression algorithms. +## EXIT CODES + +Upon successful completion, `mkdwarfs` will exit with exit code 0. If an +unrecoverable error occurs (i.e. no valid file system image has been produced), +it will exit with exit code 1. If any errors have occurred (e.g. not all input +files could be read), the exit code will be 2. + ## CATEGORIZERS Categorizers will inspect the input files in the scanning phase and try to diff --git a/src/mkdwarfs_main.cpp b/src/mkdwarfs_main.cpp index 239d0436..3395ab77 100644 --- a/src/mkdwarfs_main.cpp +++ b/src/mkdwarfs_main.cpp @@ -1376,7 +1376,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) { << err.str(); } - return prog.errors > 0; + return prog.errors > 0 ? 2 : 0; } int mkdwarfs_main(int argc, sys_char** argv) { diff --git a/test/tool_main_test.cpp b/test/tool_main_test.cpp index 4954436e..02b3de69 100644 --- a/test/tool_main_test.cpp +++ b/test/tool_main_test.cpp @@ -634,7 +634,7 @@ TEST_P(logging_test, fancy_output) { mkdwarfs_tester t; t.iol->set_terminal_fancy(true); t.os->set_access_fail("/somedir/ipsum.py"); // trigger an error - EXPECT_EQ(1, t.run("-l1 -i / -o - --categorize --num-workers=8 -S 22 " + EXPECT_EQ(2, t.run("-l1 -i / -o - --categorize --num-workers=8 -S 22 " "-L 16M --progress=none --log-level=" + level)) << t.err(); @@ -1971,7 +1971,7 @@ TEST(mkdwarfs_test, recoverable_errors) { { mkdwarfs_tester t; t.os->set_access_fail("/somedir/ipsum.py"); - EXPECT_EQ(1, t.run("-i / -o - -l4")) << t.err(); + EXPECT_EQ(2, t.run("-i / -o - -l4")) << t.err(); EXPECT_THAT(t.err(), ::testing::HasSubstr("filesystem created with 1 error")); } @@ -1980,7 +1980,7 @@ TEST(mkdwarfs_test, recoverable_errors) { mkdwarfs_tester t; t.os->set_access_fail("/somedir/ipsum.py"); t.os->set_access_fail("/baz.pl"); - EXPECT_EQ(1, t.run("-i / -o - -l4")) << t.err(); + EXPECT_EQ(2, t.run("-i / -o - -l4")) << t.err(); EXPECT_THAT(t.err(), ::testing::HasSubstr("filesystem created with 2 errors")); }