aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/hush.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 196bdbe97..fc8940d3d 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7336,6 +7336,7 @@ static void dump_cmd_in_x_mode(char **argv)
7336static void if_command_vV_print_and_exit(char opt_vV, char *cmd, const char *explanation) 7336static void if_command_vV_print_and_exit(char opt_vV, char *cmd, const char *explanation)
7337{ 7337{
7338 char *to_free; 7338 char *to_free;
7339
7339 if (!opt_vV) 7340 if (!opt_vV)
7340 return; 7341 return;
7341 7342
@@ -7343,14 +7344,15 @@ static void if_command_vV_print_and_exit(char opt_vV, char *cmd, const char *exp
7343 if (!explanation) { 7344 if (!explanation) {
7344 char *path = getenv("PATH"); 7345 char *path = getenv("PATH");
7345 explanation = to_free = find_executable(cmd, &path); /* path == NULL is ok */ 7346 explanation = to_free = find_executable(cmd, &path); /* path == NULL is ok */
7347 if (!explanation)
7348 _exit(1); /* PROG was not found */
7346 if (opt_vV != 'V') 7349 if (opt_vV != 'V')
7347 cmd = to_free; /* -v PROG prints "/path/to/PROG" */ 7350 cmd = to_free; /* -v PROG prints "/path/to/PROG" */
7348 } 7351 }
7349 if (explanation) 7352 printf((opt_vV == 'V') ? "%s is %s\n" : "%s\n", cmd, explanation);
7350 printf((opt_vV == 'V') ? "%s is %s\n" : "%s\n", cmd, explanation);
7351 free(to_free); 7353 free(to_free);
7352 fflush_all(); 7354 fflush_all();
7353 _exit(explanation == NULL); /* exit 1 if PROG was not found */ 7355 _exit(0);
7354} 7356}
7355#else 7357#else
7356# define if_command_vV_print_and_exit(a,b,c) ((void)0) 7358# define if_command_vV_print_and_exit(a,b,c) ((void)0)