04f0acee3f
- Update to version 2.10: * perltidy: associate *.t (#338) * perl: fix completion with space between option and argument * _variables: add TERM and LC_* completion (#353) * autotools: Replace pkgdatadir with datadir * pkg-config: Relative paths * pkg-config: generate Name from autotools PACKAGE * ssh: option and argument completion updates (#332) * test_arp: Skip if ARP tables are empty * test_chromium_browser: Skip test_2 if 'chromium-browser --help' fails * test_rpm2tgz: Fix expected output * cppcheck: Add new standards to --std option. (#356) * apt-get: fix pkg version completion if it contains a colon (#351) * test: bump black to >=19.10b0 * ssh, scp, sftp, ssh-copy-id, curl: improve identity file completion * update-rc.d: indentation fix * update-rc.d: remove dead code * screen: add serial device basic arg (non)completion * screen: add //telnet completion * test: add some trivial perl -E/-e cases * perl: indentation fixes * curl: make @filename completion do the right thing with dirs * _filedir: avoid duplicate dirs internally, and a compgen -d call for files * _filedir: remove unused $x * bash_completion.sh: shellcheck SC2086 fixes * test: shellcheck config cleanups * shellcheck: add some option arg (non)completions OBS-URL: https://build.opensuse.org/request/show/760990 OBS-URL: https://build.opensuse.org/package/show/shells/bash-completion?expand=0&rev=102
92 lines
2.6 KiB
Diff
92 lines
2.6 KiB
Diff
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
|
|
@@ -6,27 +6,41 @@ _lvm_filedir()
|
|
_filedir
|
|
}
|
|
|
|
+_lvm_verbose()
|
|
+{
|
|
+ local silent=$(sed -n -e "s|^[ \t]*silent[ \t]*=[ \t]*\([01]\)|\1|p" /etc/lvm/lvm.conf)
|
|
+ test ${silent:-0} -eq 1
|
|
+}
|
|
+
|
|
_lvm_volumegroups()
|
|
{
|
|
- COMPREPLY=( $(compgen -W "$(vgscan 2>/dev/null | \
|
|
+ local verbose
|
|
+ _lvm_verbose && verbose=-v
|
|
+ COMPREPLY=( $(compgen -W "$( vgscan $verbose 2>/dev/null | \
|
|
command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur") )
|
|
}
|
|
|
|
_lvm_physicalvolumes_all()
|
|
{
|
|
- COMPREPLY=( $(compgen -W "$(pvscan 2>/dev/null | \
|
|
+ local verbose
|
|
+ _lvm_verbose && verbose=-v
|
|
+ COMPREPLY=( $(compgen -W "$( pvscan $verbose 2>/dev/null | \
|
|
command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p' )" -- "$cur") )
|
|
}
|
|
|
|
_lvm_physicalvolumes()
|
|
{
|
|
- COMPREPLY=( $(compgen -W "$(pvscan 2>/dev/null | \
|
|
+ local verbose
|
|
+ _lvm_verbose && verbose=-v
|
|
+ COMPREPLY=( $(compgen -W "$( pvscan $verbose 2>/dev/null | \
|
|
command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur") )
|
|
}
|
|
|
|
_lvm_logicalvolumes()
|
|
{
|
|
- COMPREPLY=( $(compgen -W "$(lvscan 2>/dev/null | \
|
|
+ local verbose
|
|
+ _lvm_verbose && verbose=-v
|
|
+ COMPREPLY=( $(compgen -W "$( lvscan $verbose 2>/dev/null | \
|
|
command sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur") )
|
|
if [[ $cur == /dev/mapper/* ]]; then
|
|
_filedir
|
|
@@ -385,7 +399,7 @@ _vgreduce()
|
|
if [[ $args -eq 0 ]]; then
|
|
_lvm_volumegroups
|
|
else
|
|
- _lvm_physicalvolumes
|
|
+ _lvm_physicalvolumes_all
|
|
fi
|
|
fi
|
|
} &&
|
|
@@ -699,7 +713,7 @@ _lvcreate()
|
|
if [[ $args -eq 0 ]]; then
|
|
_lvm_volumegroups
|
|
else
|
|
- _lvm_physicalvolumes
|
|
+ _lvm_physicalvolumes_all
|
|
fi
|
|
fi
|
|
} &&
|