CLI: exit with error when load_config returns an error.

For now print a generic error message and exit with error on any
non-success code. Previously the code exited, but with exit code zero,
leading users / scripts to think the command had succeeded.
This commit is contained in:
David Bremner 2023-09-15 09:50:02 -03:00
parent 112c53535a
commit dbb5ff3385
2 changed files with 2 additions and 1 deletions

View file

@ -584,6 +584,8 @@ main (int argc, char *argv[])
case NOTMUCH_STATUS_SUCCESS: case NOTMUCH_STATUS_SUCCESS:
break; break;
default: default:
fputs ("Error: unable to load config file.\n", stderr);
ret = 1;
goto DONE; goto DONE;
} }

View file

@ -196,7 +196,6 @@ output=$(notmuch config get built_with.nonexistent)
test_expect_equal "$output" "false" test_expect_equal "$output" "false"
test_begin_subtest "Bad utf8 reported as error" test_begin_subtest "Bad utf8 reported as error"
test_subtest_known_broken
cp initial-config bad-config cp initial-config bad-config
printf '[query]\nq3=from:\xff\n' >>bad-config printf '[query]\nq3=from:\xff\n' >>bad-config
test_expect_code 1 "notmuch --config=./bad-config config list" test_expect_code 1 "notmuch --config=./bad-config config list"