btrfs-progs: completion: Small fixes to make debug simpler
cover btrfs-progs: completion: Small fixes to make debug simpler
For developer, it's pretty common to use "btrfs check" or "btrfs ins dump-tree" on raw dumps.
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.
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 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.18.0
PATCH 1/2 btrfs-progs: completion: Use _filedir() to replace _btrfs_devs()
For developers it's pretty common to call "btrfs check" on a raw image dump other than real block device.
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.
--- btrfs-completion | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
btrfs-completion +1 -3
@@ -6,9 +6,7 @@ _btrfs_devs() { - local DEVS - DEVS=''; while read dev; do DEVS+="$dev "; done < <(lsblk -pnro name) - COMPREPLY+=( $( compgen -W "$DEVS" -- "$cur" ) ) + _filedir } _btrfs_mnts()
Signature · 1 line
2.18.0
Re: [PATCH 1/2] btrfs-progs: completion: Use _filedir() to replace _btrfs_devs()
Quoted 2 lines · Qu Wenruo
For developers it's pretty common to call "btrfs check" on a raw image dump other than real block device.
I'd be less concerned about developers' environment rather than the situations where users want to run check and won't accidentally screw up. So completing from filenames should be safe here, the typical use will probably want something starting with /dev/ and confusion with random files named 'sda' is highly unlikely.
Quoted 14 lines
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 <[email protected]>--- btrfs-completion | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)btrfs-completion +0
-0
btrfs-completion line 9
Quoted 7 lines
btrfs-completion +1
-3@@ -6,9 +6,7 @@ _btrfs_devs() { - local DEVS - DEVS=''; while read dev; do DEVS+="$dev "; done < <(lsblk -pnro name) - COMPREPLY+=( $( compgen -W "$DEVS" -- "$cur" ) ) + _filedir
This is not a good style, the function is says "devices" and actually does "all files". It's used for several other commands where completing files might not be a good idea.
If you want to use _filedir, then use it and don't obscure it.
Re: [PATCH 1/2] btrfs-progs: completion: Use _filedir() to replace _btrfs_devs()
Quoted 9 lines · David Sterba
Quoted 2 lines · Qu Wenruo
For developers it's pretty common to call "btrfs check" on a raw image dump other than real block device.
I'd be less concerned about developers' environment rather than the situations where users want to run check and won't accidentally screw up. So completing from filenames should be safe here, the typical use will probably want something starting with
/dev/and confusion with random files named 'sda' is highly unlikely.
Yep, _filedir() is just a superset of the original devices. So for original user case, user only needs extra "/de" to initial the completion and then it should work mostly fine.
Although it could be further enhanced to only complete certain types, including regular file (for raw dump), block devices (end user use case).
Quoted 27 lines
Quoted 15 lines
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 <[email protected]>--- btrfs-completion | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)btrfs-completion +0
-0btrfs-completion line 9
Quoted 7 lines
btrfs-completion +1
-3@@ -6,9 +6,7 @@ _btrfs_devs() { - local DEVS - DEVS=''; while read dev; do DEVS+="$dev "; done < <(lsblk -pnro name) - COMPREPLY+=( $( compgen -W "$DEVS" -- "$cur" ) ) + _filedirThis is not a good style, the function is says "devices" and actually does "all files". It's used for several other commands where completing files might not be a good idea.
Quoted 1 line
If you want to use
_filedir, then use it and don't obscure it.
Right, I'll just discard the _btrfs_devs() wrapper.
Thanks,
Qu
Quoted 1 line
PATCH 2/2 btrfs-progs: completion: Let dump-tree/dump-super/inode-resolve to accept any file
In reply to Qu WenruoFor 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.
--- btrfs-completion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
btrfs-completion +1 -1
@@ -133,7 +133,7 @@ _btrfs() _btrfs_mnts return 0 ;; - rootid) + dump-tree|dump-super|rootid|inode-resolve) _filedir return 0 ;;
Signature · 1 line
2.18.0
This is useful.
Quoted 17 lines · Qu Wenruo
For developer, it's pretty common to use "btrfs check" or "btrfs ins dump-tree" on raw dumps.
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.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 filebtrfs-completion | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)