]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
birdc: Do not execute cmd on noninteractive help request
authorInrin <inrin@caesia.net>
Tue, 6 Feb 2024 18:03:14 +0000 (19:03 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Tue, 6 Feb 2024 18:03:14 +0000 (19:03 +0100)
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.

client/birdc.c

index f1aea2fee60f819b3a0c45e01708ef776aa650aa..3e4a64f4c51ac7dbb0ee8eb6c3edd74cdfb4f94d 100644 (file)
@@ -136,6 +136,9 @@ input_help(int arg, int key UNUSED)
   input_start_list();
   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);
   input_stop_list();
   return 0;
 }