0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

birdc: Do not execute cmd on noninteractive help request

The help command triggered by '?' keeps the message in readline buffer,
so it could be edited. For noninteractive shell it leads to an unexpected
side effect that `echo <cmd> ? | birdc` executes the command <cmd> after
showing its help. Avoid this by clearing the readline buffer in such case.
This commit is contained in:
Inrin 2024-02-06 19:03:14 +01:00 committed by Ondrej Zajicek
parent ff2ebdc7e1
commit 0b52f7c01f

View File

@ -136,6 +136,9 @@ input_help(int arg, int key UNUSED)
input_start_list(); input_start_list();
cmd_help(rl_line_buffer, rl_point); cmd_help(rl_line_buffer, rl_point);
rl_undo_command(1, 0); rl_undo_command(1, 0);
/* <cmd> ? is "internal". Do not submit command in non interactive session */
if (!interactive)
rl_replace_line("", 0);
input_stop_list(); input_stop_list();
return 0; return 0;
} }