[Bug 1272247] [NEW] Autocompletion of LVM volume groups, physical volumes and logical volumes does not work

Maarten Bezemer maarten.bezemer at gmail.com
Fri Jan 24 10:04:02 UTC 2014


Public bug reported:

In order to get the details of volume groups, physical volumes and
logical volumes for the variety of LVM commands the bash completion
script uses vgscan, pvscan and lvscan respectively.

These commands require root permissions, so the auto completion does not
work.

Test case:

  lvextend <tab>

does not show any completions

A 'solution' (more of a hack) is to add the sudo command in front of these  scan commands (in the completion file).
For example for finding the volume groups:

_lvm_volumegroups()
{
    COMPREPLY=( $(compgen -W "$( sudo vgscan 2>/dev/null | \
        sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) )
}

When one has used sudo recently (so not login is required) the auto
completion, for the example above, works and shows the correct options.

This is obviously/unfortunately not a solution!

$ apt-cache policy bash-completion 
bash-completion:
  Installed: 1:2.1-2ubuntu1
  Candidate: 1:2.1-2ubuntu1
  Version table:
 *** 1:2.1-2ubuntu1 0
        100 /var/lib/dpkg/status
     1:2.0-1ubuntu3 0
        500 http://nl.archive.ubuntu.com/ubuntu/ saucy/main amd64 Packages

** Affects: bash-completion (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bash-completion in Ubuntu.
https://bugs.launchpad.net/bugs/1272247

Title:
  Autocompletion of LVM volume groups, physical volumes and logical
  volumes does not work

Status in “bash-completion” package in Ubuntu:
  New

Bug description:
  In order to get the details of volume groups, physical volumes and
  logical volumes for the variety of LVM commands the bash completion
  script uses vgscan, pvscan and lvscan respectively.

  These commands require root permissions, so the auto completion does
  not work.

  Test case:

    lvextend <tab>

  does not show any completions

  A 'solution' (more of a hack) is to add the sudo command in front of these  scan commands (in the completion file).
  For example for finding the volume groups:

  _lvm_volumegroups()
  {
      COMPREPLY=( $(compgen -W "$( sudo vgscan 2>/dev/null | \
          sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) )
  }

  When one has used sudo recently (so not login is required) the auto
  completion, for the example above, works and shows the correct
  options.

  This is obviously/unfortunately not a solution!

  $ apt-cache policy bash-completion 
  bash-completion:
    Installed: 1:2.1-2ubuntu1
    Candidate: 1:2.1-2ubuntu1
    Version table:
   *** 1:2.1-2ubuntu1 0
          100 /var/lib/dpkg/status
       1:2.0-1ubuntu3 0
          500 http://nl.archive.ubuntu.com/ubuntu/ saucy/main amd64 Packages

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1272247/+subscriptions



More information about the foundations-bugs mailing list