From 338abb0f045b87df5e628543800e74dec0e72cdf Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 8 Jun 2021 12:48:03 +0200 Subject: builtins + test helpers: use return instead of exit() in cmd_* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change various cmd_* functions that claim to return an "int" to use "return" instead of exit() to indicate an exit code. These were not marked with NORETURN, and by directly exit()-ing we'll skip the cleanup git.c would otherwise do (e.g. closing fd's, erroring if we can't). See run_builtin() in git.c. In the case of shell.c and sh-i18n--envsubst.c this was the result of an incomplete migration to using a cmd_main() in 3f2e2297b9 (add an extra level of indirection to main(), 2016-07-01). This was spotted by SunCC 12.5 on Solaris 10 (gcc210 on the gccfarm). Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shell.c') diff --git a/shell.c b/shell.c index cef7ffdc9e..811e13b9c9 100644 --- a/shell.c +++ b/shell.c @@ -177,7 +177,7 @@ int cmd_main(int argc, const char **argv) default: continue; } - exit(cmd->exec(cmd->name, arg)); + return cmd->exec(cmd->name, arg); } cd_to_homedir(); -- cgit v1.3