Re: [PATCH 02/10] bash-completion: disk-utils

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 27, 2013 at 10:07:44PM +0000, Sami Kerola wrote:
> diff --git a/shell-completion/mkfs b/shell-completion/mkfs
> new file mode 100644
> index 0000000..ee6a26b
> --- /dev/null
> +++ b/shell-completion/mkfs
> @@ -0,0 +1,25 @@
> +_mkfs_module()
> +{
> +	local cur prev OPTS DEVS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-t'|'--type')
> +			FSTYPES=$(for I in $(\ls /sbin/mkfs.* /usr/sbin/mkfs.* 2>/dev/null); do echo ${I##*mkfs.}; done)

The /sbin and /usr/sbin are the same directories on many systems, so you
need to de-duplicate the list or use only one directory (I suggest /sbin).

> diff --git a/shell-completion/mkswap b/shell-completion/mkswap
> new file mode 100644
> index 0000000..c847aa9
> --- /dev/null
> +++ b/shell-completion/mkswap
> @@ -0,0 +1,36 @@
> +_mkswap_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-p'|'--pagesize')
> +			COMPREPLY=( $(compgen -W "bytes" -- $cur) )
> +			return 0
> +			;;
> +		'-L'|'--label')
> +			COMPREPLY=( $(compgen -W "label" -- $cur) )
> +			return 0
> +			;;
> +		'-v'|'--swapversion')
> +			COMPREPLY=( $(compgen -W "1" -- $cur) )
> +			return 0
> +			;;
> +		'-U'|--uuid)
> +			COMPREPLY=( $(compgen -W "$(lsblk -n --output uuid)" -- $cur) )

 The -U|--uuid is not a device identifier here, it's UUID you want to
 use for the new swap superblock. So ask lsblk does not make sense. 
 (It will generate duplicate UUIDS.)

 If you do not specify -U then mkswap will generate a new. 

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux