Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
bash-completion.3771
LVM-completion-bsc946875.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File LVM-completion-bsc946875.patch of Package bash-completion.3771
There are the following problems with lvm completions: 1)_lvm_physicalvolumes() only gets PVs that belong to a VG. In some cases like pvremove we can use all PVs including those not included in any VGs. solution: Add _lvm_physicalvolumes_all to get all PVs and correct all the commands. 2)pvcreate should be able to use all block devcices. solution: Add _lvm_filedir() to use _filedir except set $cur to /dev when $cur is empty. 3)when /etc/lvm/lvm.conf silent is 1 there is no output for vg/lv/pvscan, bash-completion will not work. solution: Check the value of silent option. If it is 1 then temporarily set silent 0 and recover back to 1 after the command executed. Signed-off-by: Liuhua Wang <lwang@suse.com> Reviewed-by: Lidong Zhong <lzhong@suse.com> diff --git a/completions/lvm b/completions/lvm --- a/completions/lvm +++ b/completions/lvm @@ -1,19 +1,57 @@ # bash completion for lvm -*- shell-script -*- +_lvm_filedir() +{ + cur=${cur:-/dev/} + _filedir +} + _lvm_volumegroups() { + local silent + silent=$(sed -n -e "s|^[ \t]*silent[ \t]*=[ \t]*\([01]\)|\1|p" /etc/lvm/lvm.conf) + silent=${silent:-0} + [ $silent -eq 1 ] && sed -i "s|\(^[ \t]*silent[ \t]*=[ \t]*\)[01].*$|\10|" /etc/lvm/lvm.conf + COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \ sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) ) + + [ $silent -eq 1 ] && sed -i "s|\(^[ \t]*silent[ \t]*=[ \t]*\)[01].*$|\11|" /etc/lvm/lvm.conf +} + +_lvm_physicalvolumes_all() +{ + local silent + silent=$(sed -n -e "s|^[ \t]*silent[ \t]*=[ \t]*\([01]\)|\1|p" /etc/lvm/lvm.conf) + silent=${silent:-0} + [ $silent -eq 1 ] && sed -i "s|\(^[ \t]*silent[ \t]*=[ \t]*\)[01].*$|\10|" /etc/lvm/lvm.conf + + COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \ + sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p' )" -- "$cur" ) ) + + [ $silent -eq 1 ] && sed -i "s|\(^[ \t]*silent[ \t]*=[ \t]*\)[01].*$|\11|" /etc/lvm/lvm.conf } _lvm_physicalvolumes() { + local silent + silent=$(sed -n -e "s|^[ \t]*silent[ \t]*=[ \t]*\([01]\)|\1|p" /etc/lvm/lvm.conf) + silent=${silent:-0} + [ $silent -eq 1 ] && sed -i "s|\(^[ \t]*silent[ \t]*=[ \t]*\)[01].*$|\10|" /etc/lvm/lvm.conf + COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \ sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur" ) ) + + [ $silent -eq 1 ] && sed -i "s|\(^[ \t]*silent[ \t]*=[ \t]*\)[01].*$|\11|" /etc/lvm/lvm.conf } _lvm_logicalvolumes() { + local silent + silent=$(sed -n -e "s|^[ \t]*silent[ \t]*=[ \t]*\([01]\)|\1|p" /etc/lvm/lvm.conf) + silent=${silent:-0} + [ $silent -eq 1 ] && sed -i "s|\(^[ \t]*silent[ \t]*=[ \t]*\)[01].*$|\10|" /etc/lvm/lvm.conf + COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \ sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur" ) ) if [[ $cur == /dev/mapper/* ]]; then @@ -23,6 +61,8 @@ _lvm_logicalvolumes() [[ ${COMPREPLY[i]} == */control ]] && unset COMPREPLY[i] done fi + + [ $silent -eq 1 ] && sed -i "s|\(^[ \t]*silent[ \t]*=[ \t]*\)[01].*$|\11|" /etc/lvm/lvm.conf } _lvm_units() @@ -96,7 +136,7 @@ _pvs() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi } && complete -F _pvs pvs @@ -116,7 +156,7 @@ _pvdisplay() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi } && complete -F _pvdisplay pvdisplay @@ -136,7 +176,7 @@ _pvchange() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi } && complete -F _pvchange pvchange @@ -168,7 +208,7 @@ _pvcreate() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_filedir fi } && complete -F _pvcreate pvcreate @@ -206,7 +246,7 @@ _pvremove() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi } && complete -F _pvremove pvremove @@ -322,7 +362,7 @@ _vgcreate() if [[ $args -eq 0 ]]; then _lvm_volumegroups else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi fi } && @@ -412,7 +452,7 @@ _vgextend() if [[ $args -eq 0 ]]; then _lvm_volumegroups else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi fi } &&
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor