summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrestez Dan Leonard <cdleonard@gmail.com>2010-02-15 14:13:51 +0200
committerCrestez Dan Leonard <cdleonard@gmail.com>2010-02-15 14:20:37 +0200
commit6d44b8033a2993e965c8b1fa97cba9d11fa7022e (patch)
treed595f8c6c7c1b51b48797854656b720818b073c0
parent4375c4b94ea7bdd370cd771aeb3483f36a42bd9f (diff)
downloadbash-completion-6d44b8033a2993e965c8b1fa97cba9d11fa7022e.tar.gz
(umount) Parse /proc/mounts instead of mount output on Linux
This makes it possible to easily unmount paths with spaces. Those are common when automatically mounting usb devices.
-rw-r--r--contrib/mount14
1 files changed, 10 insertions, 4 deletions
diff --git a/contrib/mount b/contrib/mount
index e4a74372..6fbb24fa 100644
--- a/contrib/mount
+++ b/contrib/mount
@@ -120,12 +120,18 @@ complete -F _mount -o default -o dirnames mount
have umount &&
_umount()
{
- local cur IFS=$'\n'
-
COMPREPLY=()
- cur=`_get_cword`
- COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) )
+ local cur=`_get_cword`
+
+ if [[ $(uname -s) = Linux && -r /proc/mounts ]]; then
+ # Linux /proc/mounts is properly quoted. This is important when
+ # unmounting usb devices with pretty names.
+ _linux_fstab < /proc/mounts
+ else
+ local IFS=$'\n'
+ COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) )
+ fi
return 0
} &&