Page MenuHomePhabricator

equuleus: buster: vbash: tab completion breaks
Open, NormalPublicENHANCEMENT


Tab completion is partially broken in buster.
When logging in it works until tab-completion is executed on a system command outside of the vbash menu.

steps to reproduce:

vyos@vyos:~$ [TAB]
Possible completions:
  add           Add an object to a service
  clear         Clear system information
  clone         Clone an object
  configure     Enter configure mode
  connect       Establish a connection
  copy          Copy an object
vyos@vyos:~$ show [TAB]
Possible completions:
  bridge        Show bridging information
  cluster       Show clustering information
  configuration Show available saved configurations
  conntrack     Show conntrack entries in the conntrack table
vyos@vyos:~$ ls [TAB]
  Invalid command: set
+o tag [noglob invalid]

  Invalid command: set
-o tag [noglob invalid]

.bash_history  .bashrc        .profile
.bash_logout   .gnupg/        .ssh/
vyos@vyos:~$ [TAB]
Possible completions:


Tab completion is now broken until the user spawns a new bash process..


Difficulty level
Unknown (require assessment)
Why the issue appeared?
Will be filled on close

Event Timeline

runar triaged this task as Normal priority.Aug 22 2019, 7:48 AM
runar created this task.
jjakob added a subscriber: jjakob.Thu, Sep 5, 12:18 AM

Here's the output of set -x redirected to a file when doing "ls <TAB>" as root.

At first glance it seems like a call to "set -o tag" from within a script is interpreted as an argument to the template "set" node somewhere, which causes it to break.
If anyone wants to dig in to vyatta-op, this is a starting point.

The same, but on current (jessie):

The above 2 files can be diffed to see where the bug is triggered.
The _filedir function from /usr/share/bash-completion/bash_completion was changed, the offending part is:

reset=$(shopt -po noglob); set -o noglob
toks=( $( compgen -d -- "$cur" ) )
eval $reset

when eval is called, it expands to eval 'set -o noglob' which triggers _vyatta_op_run set -o noglob, which chokes on the input.
_vyatta_op_run was set up as alias for "set" in

eval alias ${cmd:0:$pos}=\'_vyatta_op_run ${cmd:0:$pos}\'

due to "set" being part of the templates.

jjakob added a comment.Sat, Sep 7, 9:12 PM

It still fails in config mode:

vyos@vyos# ls <TAB>
  Configuration path [-o] is not valid
  Set failed

  Configuration path [-o] is not valid
  Set failed

More debugging is needed. But the op-mode and root completion work now.