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]: https://github.com/karelzak/util-linux/issues/842#issuecomment-
523450243
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
return 0
;;
esac
- COMPREPLY=( $(compgen -W "$(find -L /dev/ -path /dev/fd -prune \
- -o -type b -print 2>/dev/null)" -- $cur) )
+ COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
return 0
}
complete -F _fsck_module fsck
return 0
;;
esac
- local IFS=$'\n'
- compopt -o filenames
- COMPREPLY=( $(compgen -f -- $cur) )
+ COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
return 0
}
complete -F _fsck.cramfs_module fsck.cramfs
return 0
;;
esac
- COMPREPLY=( $(compgen -W "$(lsblk -pnro name) /path/to/file" -- $cur) )
+ COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
return 0
}
complete -F _mkfs_module mkfs
return 0
;;
esac
- COMPREPLY=( $(compgen -W "$(lsblk -pnro name) /path/to/file" -- $cur) )
+ COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
return 0
}
complete -F _mkfs.bfs_module mkfs.bfs
return 0
;;
esac
- local IFS=$'\n'
- compopt -o filenames
- COMPREPLY=( $(compgen -f -- $cur) )
+ COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
return 0
}
complete -F _mkfs.cramfs_module mkfs.cramfs
return 0
;;
esac
- local IFS=$'\n'
- compopt -o filenames
- COMPREPLY=( $(compgen -f -- $cur) )
+ COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
return 0
}
complete -F _mkswap_module mkswap