[Bash-completion-devel] [bash-completion-Bugs][314716] LVM completion fixes and enhancements (failglob, sizes...)

bash-completion-bugs at alioth.debian.org bash-completion-bugs at alioth.debian.org
Wed Jun 11 18:06:46 UTC 2014


bash-completion-Bugs item #314716 was changed at 11/06/2014 20:06 by Dams Nadé
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=314716&group_id=100114

Status: Open
Priority: 3
Submitted By: Dams Nadé (anvil-guest)
Assigned to: Nobody (None)
Summary: LVM completion fixes and enhancements (failglob, sizes...) 
Distribution: None
Originally reported in: None
Milestone: None
Status: None
Original bug number: 


Initial Comment:
Please find attached 3 patches for LVM :


* 0001-lvm-_lvm_count_args-parameter-must-be-quoted-in-orde.patch :
In completions/lvm, the _lvm_count_args functions takes a pattern as parameter. In the rest of the file, the given parameter is not correctly quoted.

* 0002-lvm-_lvm-using-a-single-pattern-case-and-invoking-fu.patch
A purely esthetic change, which shortens the 'case' statement in _lvm.

* 0003-lvm-_lvm_sizes-new-implementation-able-to-handle-rel.patch
A new implementation for _lvm_sizes. This should fix the relative-size completion issue described in [#311391].

----------------------------------------------------------------------

Comment By: Dams Nadé (anvil-guest)
Date: 11/06/2014 20:06

Message:
Let me explain the patches a bit, then, just so that the reader can understand a bit more.


0005-lvm-dynamically-compute-the-available-field-names-fo.patch
The -o option of lvs, pvs and vgs commands acts like 'ps -o field1,field2'. The bash completion currently only propose a reduced and hardcoded list of field names. The complete field names list can be seen in if you run any of those 3 commands with "-o any_bogus_field_name".

The _lvpvvgs_fields function parses this output, and fill 3 variables (lvs_fields, pvs_fields and vgs_fields), which are simply reused right after by the completion functions. That way, the lists does not have to be manually maintained.

0004-lvm-using-vgs-pvs-lvs-in-_lvm_volumegroups-_lvm_phys.patch
The _lvm_volumegroups function currently in bash completion uses vgscan and parses its output with a sed. As explained right above, the vgs command be used to obtained any information about volume groups by simply specifying the fields we want with the -o option.

e.g
The vgscan | sed, would grab the "Found volume group" line and print "fedora".
[anvil at tartine ~/git/bash-completion]# sudo vgscan 
  Reading all physical volumes.  This may take a while...
  Found volume group "fedora" using metadata type lvm2

You can just print the volume groups names by using vgs.
[anvil at tartine ~/git/bash-completion]# sudo vgs -o vg_name
  VG    
  fedora
The --noheadings option just remove the upper line containing fields names.
The same way, we can use lvs and pvs to obtain logical and physical volumes names.

0003-lvm-_lvm_sizes-new-implementation-able-to-handle-rel.patch
The _lvm_sizes function currently only proposes units single letters, which is a kinda useless (and buggy, it seems according to #311391). The new function can construct a number. Since some LVM binaries (lvextend, ...) accept relative numbers, the new function can also construct this kind of numbers, when given proper parameters.

----------------------------------------------------------------------

Comment By: Ville Skyttä  (scop-guest)
Date: 07/06/2014 11:35

Message:
0001 and 0002 (with slight modifications) applied, hopefully someone who actually uses lvm will take a look at the rest.

----------------------------------------------------------------------

Comment By: Dams Nadé (anvil-guest)
Date: 07/06/2014 00:41

Message:
0005-lvm-dynamically-compute-the-available-field-names-fo.patch :
The currently provided list of field names for pvs/lvs/vgs is incomplete. I suggest parsing these commands stderr to compute the full list of available fields, thus enhancing the completion.

----------------------------------------------------------------------

Comment By: Dams Nadé (anvil-guest)
Date: 06/06/2014 23:49

Message:
* 0004-lvm-using-vgs-pvs-lvs-in-_lvm_volumegroups-_lvm_phys.patch
We can remove the use of sed in the functions providing pv/vg/lv names by using pvs/vgs/lvs instead of pvscan/vgscan/lvscan.

----------------------------------------------------------------------

You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=314716&group_id=100114



More information about the Bash-completion-devel mailing list