Hi!

A pal of mine noticed that `echo <cmd> ? | birdc` executes the command
<cmd> after showing it's help text is shown. I later confirmed that `birdcl` in
comparison to `birdc` does not show this behaviour.

Since this is a non intuitive side effect on birdc's side, here a
proposed patch to align birdc and birdcl's behaviour.

Please advise if fixing it on another part might be preferred.
I chose birdc.c, to minimize the changes needed.

Below a full report:
--------------------------------------------
# Scenario
## Setup
./bird -l

## birdcl no side effect
bird (v2.14)> echo 'restrict ?' | ./birdcl -l
BIRD v2.14 ready.
bird> restrict ?
restrict                                       Restrict current CLI session to 
safe commands
bird>
bird (v2.14)>

## birdc side effect
bird (v2.14)> echo 'restrict ?' | ./birdc -l
BIRD v2.14 ready.
bird> restrict ?
restrict                                       Restrict current CLI session to 
safe commands
bird> restrict
Access restricted
bird (v2.14)>

# Expected behaviour
Like birdcl, just show help and exit

# Actual behaviour
Executes the <cmd> after showing the help

# Tested version
BIRD v2.14
(birdc.c last edited on 2017, so I guess this is on all versions the same)
--------------------------------------------
diff --git a/client/birdc.c b/client/birdc.c
index f1aea2fe..a415d20c 100644
--- a/client/birdc.c
+++ b/client/birdc.c
@@ -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 in non interactive sessiosn */
+  if (!interactive)
+    rl_replace_line("", 0);
   input_stop_list();
   return 0;
 }

Reply via email to