All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] btrfs-progs: completion: Small fixes to make debug simpler
@ 2018-08-13  6:02 Qu Wenruo
  2018-08-13  6:02 ` [PATCH v2 1/2] btrfs-progs: completion: Use _filedir() to replace _btrfs_devs() Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Qu Wenruo @ 2018-08-13  6:02 UTC (permalink / raw)
  To: linux-btrfs

For developer, it's pretty common to use "btrfs check" or "btrfs ins
dump-tree" on raw dumps.
Even for end user, they may hit case where they need to run "btrfs check"
on raw images.

However "btrfs check" can only complete real block devices, and
"btrfs inspect dump-tree" can only complete dir.

Make them to use _filedir() so any filename can be completed and save us
developer a little time and nerve hitting that holy tab.

changelog:
v2:
  Discard _btrfs_dev() macro completely.

Qu Wenruo (2):
  btrfs-progs: completion: Use _filedir() to replace _btrfs_devs()
  btrfs-progs: completion: Let dump-tree/dump-super/inode-resolve to
    accept any file

 btrfs-completion | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

-- 
2.18.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] btrfs-progs: completion: Use _filedir() to replace _btrfs_devs()
  2018-08-13  6:02 [PATCH v2 0/2] btrfs-progs: completion: Small fixes to make debug simpler Qu Wenruo
@ 2018-08-13  6:02 ` Qu Wenruo
  2018-08-13  6:02 ` [PATCH v2 2/2] btrfs-progs: completion: Let dump-tree/dump-super/inode-resolve to accept any file Qu Wenruo
  2018-08-20 13:40 ` [PATCH v2 0/2] btrfs-progs: completion: Small fixes to make debug simpler David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2018-08-13  6:02 UTC (permalink / raw)
  To: linux-btrfs

For developers it's pretty common to call "btrfs check" on a raw image
dump other than real block device.
It's also possible to end users to do some tests on loop devices.

So current _btrfs_devs() is really making things worse. Use _filedir()
to replace _btrfs_devs() so it can complete any filenames, no matter if
it's just a file or a real block device.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 btrfs-completion | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/btrfs-completion b/btrfs-completion
index ae683f4ecf61..b7628e6984c5 100644
--- a/btrfs-completion
+++ b/btrfs-completion
@@ -4,13 +4,6 @@
 # (http://lists.alioth.debian.org/pipermail/bash-completion-devel/2013-June/004868.html)
 # edited by John C F <john.ch.fr at gmail.com> on 2015-02-02
 
-_btrfs_devs()
-{
-	local DEVS
-	DEVS=''; while read dev; do DEVS+="$dev "; done < <(lsblk -pnro name)
-	COMPREPLY+=( $( compgen -W "$DEVS" -- "$cur" ) )
-}
-
 _btrfs_mnts()
 {
 	local MNTS
@@ -68,14 +61,14 @@ _btrfs()
 				opts="$commands_scrub"
 				;;
 			check)
-				_btrfs_devs
+				_filedir
 				return 0
 				;;
 			rescue)
 				opts="$commands_rescue"
 				;;
 			restore)
-				_btrfs_devs
+				_filedir
 				return 0
 				;;
 			inspect-internal)
@@ -120,13 +113,13 @@ _btrfs()
 						;;
 					label)
 						_btrfs_mnts
-						_btrfs_devs
+						_filedir
 						return 0
 						;;
 				esac
 				;;
 			device|rescue)
-				_btrfs_devs
+				_filedir
 				return 0
 				;;
 			inspect-internal)
@@ -156,7 +149,7 @@ _btrfs()
 						return 0
 						;;
 					start)
-						_btrfs_devs
+						_filedir
 						return 0
 						;;
 				esac
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] btrfs-progs: completion: Let dump-tree/dump-super/inode-resolve to accept any file
  2018-08-13  6:02 [PATCH v2 0/2] btrfs-progs: completion: Small fixes to make debug simpler Qu Wenruo
  2018-08-13  6:02 ` [PATCH v2 1/2] btrfs-progs: completion: Use _filedir() to replace _btrfs_devs() Qu Wenruo
@ 2018-08-13  6:02 ` Qu Wenruo
  2018-08-20 13:40 ` [PATCH v2 0/2] btrfs-progs: completion: Small fixes to make debug simpler David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2018-08-13  6:02 UTC (permalink / raw)
  To: linux-btrfs

For dump-tree/dump-super the completion uses default filedir -d, which
is far from convenient.
Use filedir for dump-tree/dump-super/inode-resolve just like rootid.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 btrfs-completion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/btrfs-completion b/btrfs-completion
index b7628e6984c5..6ae57d1b752b 100644
--- a/btrfs-completion
+++ b/btrfs-completion
@@ -128,7 +128,7 @@ _btrfs()
 						_btrfs_mnts
 						return 0
 						;;
-					rootid)
+					dump-tree|dump-super|rootid|inode-resolve)
 						_filedir
 						return 0
 						;;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] btrfs-progs: completion: Small fixes to make debug simpler
  2018-08-13  6:02 [PATCH v2 0/2] btrfs-progs: completion: Small fixes to make debug simpler Qu Wenruo
  2018-08-13  6:02 ` [PATCH v2 1/2] btrfs-progs: completion: Use _filedir() to replace _btrfs_devs() Qu Wenruo
  2018-08-13  6:02 ` [PATCH v2 2/2] btrfs-progs: completion: Let dump-tree/dump-super/inode-resolve to accept any file Qu Wenruo
@ 2018-08-20 13:40 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2018-08-20 13:40 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Mon, Aug 13, 2018 at 02:02:42PM +0800, Qu Wenruo wrote:
> For developer, it's pretty common to use "btrfs check" or "btrfs ins
> dump-tree" on raw dumps.
> Even for end user, they may hit case where they need to run "btrfs check"
> on raw images.
> 
> However "btrfs check" can only complete real block devices, and
> "btrfs inspect dump-tree" can only complete dir.
> 
> Make them to use _filedir() so any filename can be completed and save us
> developer a little time and nerve hitting that holy tab.
> 
> changelog:
> v2:
>   Discard _btrfs_dev() macro completely.
> 
> Qu Wenruo (2):
>   btrfs-progs: completion: Use _filedir() to replace _btrfs_devs()
>   btrfs-progs: completion: Let dump-tree/dump-super/inode-resolve to
>     accept any file

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-20 16:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13  6:02 [PATCH v2 0/2] btrfs-progs: completion: Small fixes to make debug simpler Qu Wenruo
2018-08-13  6:02 ` [PATCH v2 1/2] btrfs-progs: completion: Use _filedir() to replace _btrfs_devs() Qu Wenruo
2018-08-13  6:02 ` [PATCH v2 2/2] btrfs-progs: completion: Let dump-tree/dump-super/inode-resolve to accept any file Qu Wenruo
2018-08-20 13:40 ` [PATCH v2 0/2] btrfs-progs: completion: Small fixes to make debug simpler David Sterba

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.