[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 38e9ef18b2150740871a569ff16c6aefd018d8a2

Ville Skyttä ville.skytta at iki.fi
Wed Apr 21 16:31:15 UTC 2010


The following commit has been merged in the master branch:
commit e270eb18e3295e10248680669485d5fa8f64a3cb
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Apr 21 19:07:17 2010 +0300

    Improve filesystem type completions.

diff --git a/CHANGES b/CHANGES
index 1bb01f2..2ffeaca 100644
--- a/CHANGES
+++ b/CHANGES
@@ -25,10 +25,10 @@ bash-completion (2.x)
   * Apply cardctl completion to pccardctl too.
   * Apply pine completion to alpine too.
   * Remove many unnecessary short option completions where long ones exist.
-  * Improve chsh, chgrp, chown, configure, cvs, gkrellm, gzip, iconv, lftp,
-    look, make, man, mdadm, modprobe, mplayer, mysqladmin, perldoc, rsync,
-    screen, service, scp, ssh, sshfs, update-alternatives, vncviewer, wget,
-    yp-tools, and general hostname completions.
+  * Improve chsh, chgrp, chown, configure, cvs, find, gkrellm, gzip, iconv,
+    lftp, look, make, man, mdadm, modprobe, mount, mplayer, mysqladmin,
+    perldoc, rsync, screen, service, scp, ssh, sshfs, update-alternatives,
+    vncviewer, wget, yp-tools, and general hostname completions.
   * Add abook and wtf completion, based on work by Raphaël Droz.
   * Add cvsps, dragon, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake,
     pack200, unpack200, pbzip2, pbunzip2, pbzcat, pigz and unpigz completions.
diff --git a/bash_completion b/bash_completion
index da40cbb..c73ea1d 100644
--- a/bash_completion
+++ b/bash_completion
@@ -950,6 +950,29 @@ _shells()
         -- "$cur" ) )
 }
 
+# This function completes on valid filesystem types
+#
+_fstypes()
+{
+    local fss
+
+    if [ -e /proc/filesystems ] ; then
+        # Linux
+        fss="$( cut -d$'\t' -f2 /proc/filesystems )
+             $( awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null )"
+    else
+        # Generic
+        fss="$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2>/dev/null )
+             $( awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null )
+             $( awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null )
+             $( awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null )
+             $( [ -d /etc/fs ] && command ls /etc/fs )"
+    fi
+
+    [ -n "$fss" ] && \
+        COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$fss" -- "$cur" ) )
+}
+
 # Get real command.
 # - arg: $1  Command
 # - stdout:  Filename of command in PATH with possible symbolic links resolved.
diff --git a/contrib/findutils b/contrib/findutils
index aa0e9b1..e6726e9 100644
--- a/contrib/findutils
+++ b/contrib/findutils
@@ -22,10 +22,11 @@ _find()
             return 0
             ;;
         -fstype)
-            # this is highly non-portable
-            [ -e /proc/filesystems ] &&
-            COMPREPLY=( $( compgen -W "$( cut -d$'\t' -f2 /proc/filesystems )" \
-                -- "$cur" ) )
+            _fstypes
+            if [[ "$( uname -s )" == *BSD ]] ; then
+                COMPREPLY=( "${COMPREPLY[@]}" \
+                    $( compgen -W 'local rdonly' -- "$cur" ) )
+            fi
             return 0
             ;;
         -gid)
diff --git a/contrib/mount b/contrib/mount
index daf472c..a22b078 100644
--- a/contrib/mount
+++ b/contrib/mount
@@ -82,6 +82,14 @@ _mount()
     COMPREPLY=()
     cur=`_get_cword ':'`
     prev=`_get_pword ':'`
+
+    case $prev in
+        -t|--types)
+            _fstypes
+            return 0
+            ;;
+    esac
+
     [[ "$cur" == \\ ]] && cur="/"
 
     if [[ "$cur" == *:* ]]; then
diff --git a/test/lib/completions/find.exp b/test/lib/completions/find.exp
index 8009fdd..711045c 100644
--- a/test/lib/completions/find.exp
+++ b/test/lib/completions/find.exp
@@ -17,6 +17,12 @@ assert_complete_any "find "
 sync_after_int
 
 
+assert_complete_any "find -fstype "
+
+
+sync_after_int
+
+
 set options [list -amin -anewer -atime -cmin -cnewer -ctime -daystart -depth -empty -exec \
     -false -fls -follow -fprint -fprint0 -fprintf -fstype -gid -group -help -ilname -iname \
     -inum -ipath -iregex -iwholename -links -lname -ls -maxdepth -mindepth -mmin -mount \
diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp
index b3ee978..38d93e3 100644
--- a/test/lib/completions/mount.exp
+++ b/test/lib/completions/mount.exp
@@ -44,6 +44,12 @@ assert_complete_any "mount "
 sync_after_int
 
 
+assert_complete_any "mount -t "
+
+
+sync_after_int
+
+
 set test "Check completing nfs mounts"
 set expected [list /test/path /test/path2 /second/path]
 set cmd "mount mocksrv:/"

-- 
bash-completion



More information about the Bash-completion-commits mailing list