All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: linux-nvdimm@lists.01.org
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	Pavel Tatashin <pasha.tatashin@soleen.com>
Subject: [ndctl PATCH v5 11/13] contrib/ndctl: fix region-id completions for daxctl
Date: Fri, 28 Jun 2019 13:11:08 -0600	[thread overview]
Message-ID: <20190628191110.21428-12-vishal.l.verma@intel.com> (raw)
In-Reply-To: <20190628191110.21428-1-vishal.l.verma@intel.com>

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(-)

diff --git a/contrib/ndctl b/contrib/ndctl
index 396a344..cacee2d 100755
--- a/contrib/ndctl
+++ b/contrib/ndctl
@@ -531,8 +531,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()
@@ -561,10 +567,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
-- 
2.20.1

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  parent reply	other threads:[~2019-06-28 19:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28 19:10 [ndctl PATCH v5 00/13] daxctl: add a new reconfigure-device command Vishal Verma
2019-06-28 19:10 ` [ndctl PATCH v5 01/13] libdaxctl: add interfaces to get ctx and check device state Vishal Verma
2019-06-28 19:10 ` [ndctl PATCH v5 02/13] libdaxctl: add interfaces to enable/disable devices Vishal Verma
2019-06-28 19:11 ` [ndctl PATCH v5 03/13] libdaxctl: add an interface to retrieve the device resource Vishal Verma
2019-06-28 19:11 ` [ndctl PATCH v5 04/13] libdaxctl: add a 'daxctl_memory' object for memory based operations Vishal Verma
2019-06-28 19:11 ` [ndctl PATCH v5 05/13] daxctl/list: add target_node for device listings Vishal Verma
2019-06-28 19:11 ` [ndctl PATCH v5 06/13] libdaxctl: add an interface to get the mode for a dax device Vishal Verma
2019-06-28 19:11 ` [ndctl PATCH v5 07/13] daxctl: add a new reconfigure-device command Vishal Verma
2019-06-28 19:11 ` [ndctl PATCH v5 08/13] Documentation/daxctl: add a man page for daxctl-reconfigure-device Vishal Verma
2019-06-28 19:11 ` [ndctl PATCH v5 09/13] daxctl: add commands to online and offline memory Vishal Verma
2019-06-28 19:11 ` [ndctl PATCH v5 10/13] Documentation: Add man pages for daxctl-{on, off}line-memory Vishal Verma
2019-06-28 19:11 ` Vishal Verma [this message]
2019-06-28 19:11 ` [ndctl PATCH v5 12/13] contrib/ndctl: add bash-completion for the new daxctl commands Vishal Verma
2019-06-28 19:11 ` [ndctl PATCH v5 13/13] test: Add a unit test for daxctl-reconfigure-device and friends Vishal Verma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190628191110.21428-12-vishal.l.verma@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=pasha.tatashin@soleen.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.