Skip to content
Permalink
Browse files

bash-completion: (umount) use findmnt, escape a space in paths

 # mount /dev/sdc1 /mnt/test/foo\ bar
 # umount <tab>

has to return "/mnt/test/foo\ bar".

Changes:

 * don't use mount | awk output, we have findmnt
 * force compgen use \n as entries separator

Addresses: #539
Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information...
karelzak committed Nov 16, 2017
1 parent d9a388d commit 75f03badd7ed9f1dd951863d75e756883d3acc55
Showing with 5 additions and 4 deletions.
  1. +5 −4 bash-completion/umount
@@ -40,9 +40,10 @@ _umount_module()
return 0
;;
esac
local DEVS_MPOINTS
DEVS_MPOINTS="$(mount | awk '{print $1, $3}')"
COMPREPLY=( $(compgen -W "$DEVS_MPOINTS" -- $cur) )
return 0

local oldifs=$IFS
IFS=$'\n'
COMPREPLY=( $( compgen -W '$(findmnt -lno TARGET | sed "s/\([[:blank:]]\)/\\\\\1/g")' -- "$cur" ) )
IFS=$oldifs
}
complete -F _umount_module umount

0 comments on commit 75f03ba

Please sign in to comment.
You can’t perform that action at this time.