[git commit] hush: tweak command -vV printing code, no logic changes

Denys Vlasenko vda.linux at googlemail.com
Fri Jan 12 15:17:59 UTC 2018


commit: https://git.busybox.net/busybox/commit/?id=afb73a25ea9b046f0fb2fa83a6d75b15bd952716
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/hush.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/shell/hush.c b/shell/hush.c
index 196bdbe..fc8940d 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7336,6 +7336,7 @@ static void dump_cmd_in_x_mode(char **argv)
 static void if_command_vV_print_and_exit(char opt_vV, char *cmd, const char *explanation)
 {
 	char *to_free;
+
 	if (!opt_vV)
 		return;
 
@@ -7343,14 +7344,15 @@ static void if_command_vV_print_and_exit(char opt_vV, char *cmd, const char *exp
 	if (!explanation) {
 		char *path = getenv("PATH");
 		explanation = to_free = find_executable(cmd, &path); /* path == NULL is ok */
+		if (!explanation)
+			_exit(1); /* PROG was not found */
 		if (opt_vV != 'V')
 			cmd = to_free; /* -v PROG prints "/path/to/PROG" */
 	}
-	if (explanation)
-		printf((opt_vV == 'V') ? "%s is %s\n" : "%s\n", cmd, explanation);
+	printf((opt_vV == 'V') ? "%s is %s\n" : "%s\n", cmd, explanation);
 	free(to_free);
 	fflush_all();
-	_exit(explanation == NULL); /* exit 1 if PROG was not found */
+	_exit(0);
 }
 #else
 # define if_command_vV_print_and_exit(a,b,c) ((void)0)


More information about the busybox-cvs mailing list