2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-24 02:47:14 +00:00

5 Commits

Author SHA1 Message Date
Frode Nordahl
cfba951585 utilities/bashcomp: Fix incorrect file mode.
The bash completion scripts shipped with Open vSwitch currently
have the executable bit set.  This is problematic because the
files do not start with a shebang and as such a user may end up
executing them using the wrong shell.  When installed in a system
the bash shell will source these files and not execute them.

This also triggers Debian lintian warnings [0] and defies Debian
policy [1].

0: https://lintian.debian.org/tags/executable-not-elf-or-script
1: https://www.debian.org/doc/debian-policy/ch-files.html#scripts
Fixes: 423ede182b65 ("utilities: Add bash command-line completion script.")
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-12 15:45:42 +02:00
Ben Pfaff
804bdf738e ovs-vsctl-bashcomp: Make compatible with busybox "awk".
It seems that awk in busybox doesn't think that an empty string is part of
a larger string, but that GNU awk does.  This commit adds an extra test to
make _ovs_vsctl_check_startswith_string work either way.

This allows the following tests to pass with busybox awk:

vsctl bashcomp unit tests

  7: vsctl-bashcomp - basic verification             ok
  8: vsctl-bashcomp - argument completion            ok

Reported-by: Stuart Cardall <developer@it-offshore.co.uk>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Lance Richardson <lrichard@redhat.com>
2017-08-08 13:07:40 -07:00
Alex Wang
bb5dbe7859 ovs-vsctl-bashcomp: Avoid setting the COMP_WORDBREAKS.
Modifying $COMP_WORDBREAKS in completion script is not the recommended
as it is a global variable and the modification could affect the behavior
of other completion scripts.  As a workaround, this commit uses the
_get_comp_words_by_ref which allows user to exclude characters out of
$COMP_WORDBREAKS and reassemble input command line.  However, as a side
effect, the bash completion module cannot handle characters defined in
$COMP_WORDBREAKS (e.g. ':' and '=') correctly in the resulting completions.
Thusly, we need to trim the colon-word and equal-word prefixes from reply.

Signed-off-by: Alex Wang <alexw@nicira.com>
2015-03-20 16:42:42 -07:00
Alex Wang
ce34e37ffe ovs-vsctl-bashcomp: Fix build failure when bash version < 4.0.
The ovs-vsctl-bashcomp script does not work properly on bash (version
 < 4.0).  This commit adds test for the bash version and avoids running
the script/test when the bash version is not supported.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2015-03-13 10:44:29 -07:00
Peter Amidon
95e4a97a6f ovs-vsctl-bashcomp: Add bash command-line completion for ovs-vsctl.
This patch adds bash command-line completion script for ovs-vsctl.
Therein, codes are added to ovs-vsctl to allow it to print the
options and command arguments.  The ovs-vsctl-bashcomp.bash will
parse the vsctl command and complete on the user input.

The completion script can do the following::

- display available completions and complete on user input for
  global/local options, sub-commands, and arguments.

- query database and expand keywords like 'table/record/column/key'
  to available completions.

- deal with argument relations like 'one and more', 'zero or one'.

- complete multiple ovs-vsctl commands cascaded via '--'.

To use the script, either copy it inside /etc/bash_completion.d/
or manually run it via . ovs-vsctl-bashcomp.bash.

Signed-off-by: Peter Amidon <peter@picnicpark.org>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2015-03-12 14:17:13 -07:00