@@ -528,8 +528,14 @@ _ndctl()
__daxctl_get_devs()
{
- local opts="--devices $*"
- echo "$(daxctl list $opts | grep -E "^\s*\"chardev\":" | cut -d\" -f4)"
+ local opts=("--devices" "$*")
+ daxctl list "${opts[@]}" | grep -E "^\s*\"chardev\":" | cut -d'"' -f4
+}
+
+__daxctl_get_regions()
+{
+ local opts=("--regions" "$*")
+ daxctl list "${opts[@]}" | grep -E "^\s*\"id\":" | grep -Eo "[0-9]+"
}
__daxctlcomp()
@@ -558,10 +564,10 @@ __daxctl_comp_options()
local cur_arg=${cur##*=}
case $cur_subopt in
--region)
- opts=$(__ndctl_get_regions -i)
+ opts="$(__daxctl_get_regions -i)"
;;
--dev)
- opts=$(__daxctl_get_devs -i)
+ opts="$(__daxctl_get_devs -i)"
;;
*)
return
The completion helpers for daxctl assumed the region arguments for specifying daxctl regions were the same as ndctl regions, i.e. "regionX". This is not true - daxctl region arguments are a simple numeric 'id'. Add a new helper __daxctl_get_regions() to complete daxctl region IDs properly. While at it, fix a useless use of 'echo' in __daxctl_get_devs() and quoting in __daxctl_comp_options() Fixes: d6790a32f32c ("daxctl: Add bash-completion") Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> --- contrib/ndctl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)