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
1 changed files with 3 additions and 0 deletions

View File

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