[Bash-completion-devel] [PATCH 1/3] lvm: fix all commands that should get all PVs
Liuhua Wang
lwang at suse.com
Mon Mar 7 09:56:30 UTC 2016
_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.
So we add a new function _lvm_physicalvolumes_all() to get all PVs,
and fix all the commands that need to use _lvm_physicalvolumes_all()
instead of _lvm_physicalvolumes().
Signed-off-by: Liuhua Wang <lwang at suse.com>
Reviewed-by: Lidong Zhong <lzhong at suse.com>
---
completions/lvm | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/completions/lvm b/completions/lvm
index d04a549..1535c5c 100644
--- a/completions/lvm
+++ b/completions/lvm
@@ -6,6 +6,12 @@ _lvm_volumegroups()
sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) )
}
+_lvm_physicalvolumes_all()
+{
+ COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \
+ sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p' )" -- "$cur" ) )
+}
+
_lvm_physicalvolumes()
{
COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \
@@ -96,7 +102,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 +122,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 +142,7 @@ _pvchange()
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) )
else
- _lvm_physicalvolumes
+ _lvm_physicalvolumes_all
fi
} &&
complete -F _pvchange pvchange
@@ -206,7 +212,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 +328,7 @@ _vgcreate()
if [[ $args -eq 0 ]]; then
_lvm_volumegroups
else
- _lvm_physicalvolumes
+ _lvm_physicalvolumes_all
fi
fi
} &&
@@ -412,7 +418,7 @@ _vgextend()
if [[ $args -eq 0 ]]; then
_lvm_volumegroups
else
- _lvm_physicalvolumes
+ _lvm_physicalvolumes_all
fi
fi
} &&
--
1.8.4.5
More information about the Bash-completion-devel
mailing list