hush: tweak command -vV printing code, no logic changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
5700029c65
commit
afb73a25ea
@ -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)
|
static void if_command_vV_print_and_exit(char opt_vV, char *cmd, const char *explanation)
|
||||||
{
|
{
|
||||||
char *to_free;
|
char *to_free;
|
||||||
|
|
||||||
if (!opt_vV)
|
if (!opt_vV)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -7343,14 +7344,15 @@ static void if_command_vV_print_and_exit(char opt_vV, char *cmd, const char *exp
|
|||||||
if (!explanation) {
|
if (!explanation) {
|
||||||
char *path = getenv("PATH");
|
char *path = getenv("PATH");
|
||||||
explanation = to_free = find_executable(cmd, &path); /* path == NULL is ok */
|
explanation = to_free = find_executable(cmd, &path); /* path == NULL is ok */
|
||||||
|
if (!explanation)
|
||||||
|
_exit(1); /* PROG was not found */
|
||||||
if (opt_vV != 'V')
|
if (opt_vV != 'V')
|
||||||
cmd = to_free; /* -v PROG prints "/path/to/PROG" */
|
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);
|
free(to_free);
|
||||||
fflush_all();
|
fflush_all();
|
||||||
_exit(explanation == NULL); /* exit 1 if PROG was not found */
|
_exit(0);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define if_command_vV_print_and_exit(a,b,c) ((void)0)
|
# define if_command_vV_print_and_exit(a,b,c) ((void)0)
|
||||||
|
Loading…
Reference in New Issue
Block a user