]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: (umount) use findmnt, escape a space in paths
authorKarel Zak <kzak@redhat.com>
Thu, 16 Nov 2017 15:27:32 +0000 (16:27 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 16 Nov 2017 15:27:32 +0000 (16:27 +0100)
 # 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: https://github.com/karelzak/util-linux/issues/539
Signed-off-by: Karel Zak <kzak@redhat.com>
bash-completion/umount

index d76cb9fffde4e6ed2854e4e61c4754b54b7c2723..98c90d61a45686a5bc2468494a542ad821b28b66 100644 (file)
@@ -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