-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bash completion doesn't match non-canonical device names or files #842
Comments
I'm sure everyone agrees improvements are welcome. But why only as fallback? If there useful possibilities just list everything by default. |
For sure. I'd be happy to change I think |
Isn't there no better way to find custom devices paths than |
Sure, I could come up with a way to limit completions to block devices (either with or without fallback to regular files), but it may be annoying/surprising for users who want to run against a image file (e.g. |
hmm... add /dev/disk/by-* to the default will generate huge list with many duplicates and aliases. I think this directory should be added to the list only if user explicitly specifies /dev/disk/ on command line. The same with the current directory, for example:
I have no clue how difficult is to implement it, but it would be nice if user can control it by path prefix (/dev/disk, ./ ...) and default should be $(lsblk -pnro name) is nothing specified. |
Thanks @karelzak, sounds good to me. That should be reasonably straightforward to implement. I'll take a stab at it soon. |
Some of the fsck and mkfs commands complete differently than the others, and differently than the desired behavior.[1] Standardize on completing with $(lsblk -pnro name): * fsck: Don't complete completes on all block devices and device links under /dev immediately (which is excessive and prone to search problems). * mkfs, mkfs.bfs: Don't complete "/path/to/file" literally. I assume this was copy/pasted from example code, since it does not appear to be a valid argument unless it is a valid path, which is rare. * fsck.cramfs, mkfs, mkfs.bfs, mkfs.cramfs, mkswap: Don't complete on all filenames initially. The desired behavior is to complete filenames only if there are no canonical matches.[1] Note: A subsequent commit will add the desired fallback behavior. [1]: util-linux#842 (comment) Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
For commands which support operating on files (i.e. disk images), it is desirable for bash-completion to complete matching file names. It is also desirable to complete on block device symlinks (e.g. under /dev/disk). To complete common use cases, often on canonical device names, continue to try completion using canonical device names, then fall back to matching any file incrementally as Bash does by default.[1] [1]: util-linux#842 (comment) Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
The Bash completion scripts for commands which usually operate on block devices (
blkdiscard
,*disk
,mkfs*
) won't complete files other than the names of block devices fromlsblk -pnro name
. This excludes block devices under/dev/disk/
, disk image files, custom device nodes, and probably other things which make the tools frustrating to use in these cases.Would you be open to accepting a PR which completes these, either by default or as a fallback if
compgen -W "$(lsblk -pnro name)"
returns no matches?Thanks for considering,
Kevin
The text was updated successfully, but these errors were encountered: