]> git.ipfire.org Git - people/ms/ipfire-3.x.git/commitdiff
bash-completion: New package.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Feb 2012 14:51:59 +0000 (15:51 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Feb 2012 14:52:56 +0000 (15:52 +0100)
Adds automatic completion on command line for lots of basic
commands.

bash-completion/bash-completion-1.99-redefine_filedir.bash [new file with mode: 0644]
bash-completion/bash-completion.nm [new file with mode: 0644]
bash-completion/patches/bash-completion-1.99-noblacklist.patch [new file with mode: 0644]

diff --git a/bash-completion/bash-completion-1.99-redefine_filedir.bash b/bash-completion/bash-completion-1.99-redefine_filedir.bash
new file mode 100644 (file)
index 0000000..f8c2a38
--- /dev/null
@@ -0,0 +1,49 @@
+# This is a copy of the _filedir function in bash_completion, included
+# and (re)defined separately here because some versions of Adobe
+# Reader, if installed, are known to override this function with an
+# incompatible version, causing various problems.
+#
+# https://bugzilla.redhat.com/677446
+# http://forums.adobe.com/thread/745833
+
+_filedir()
+{
+    local i IFS=$'\n' xspec
+
+    _tilde "$cur" || return 0
+
+    local -a toks
+    local quoted tmp
+
+    _quote_readline_by_ref "$cur" quoted
+    toks=( $(
+        compgen -d -- "$quoted" | {
+            while read -r tmp; do
+                # TODO: I have removed a "[ -n $tmp ] &&" before 'printf ..',
+                #       and everything works again. If this bug suddenly
+                #       appears again (i.e. "cd /b<TAB>" becomes "cd /"),
+                #       remember to check for other similar conditionals (here
+                #       and _filedir_xspec()). --David
+                printf '%s\n' $tmp
+            done
+        }
+    ))
+
+    if [[ "$1" != -d ]]; then
+        # Munge xspec to contain uppercase version too
+        # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306
+        xspec=${1:+"!*.@($1|${1^^})"}
+        toks+=( $( compgen -f -X "$xspec" -- $quoted ) )
+    fi
+
+    # If the filter failed to produce anything, try without it if configured to
+    [[ -n ${COMP_FILEDIR_FALLBACK:-} && \
+        -n "$1" && "$1" != -d && ${#toks[@]} -lt 1 ]] && \
+        toks+=( $( compgen -f -- $quoted ) )
+
+    if [[ ${#toks[@]} -ne 0 ]]; then
+        # 2>/dev/null for direct invocation, e.g. in the _filedir unit test
+        compopt -o filenames 2>/dev/null
+        COMPREPLY+=( "${toks[@]}" )
+    fi
+} # _filedir()
diff --git a/bash-completion/bash-completion.nm b/bash-completion/bash-completion.nm
new file mode 100644 (file)
index 0000000..6e0eda4
--- /dev/null
@@ -0,0 +1,39 @@
+###############################################################################
+# IPFire.org    - An Open Source Firewall Solution                            #
+# Copyright (C) - IPFire Development Team <info@ipfire.org>                   #
+###############################################################################
+
+name       = bash-completion
+version    = 1.99
+release    = 1
+arch       = noarch
+
+groups     = Development/Languages
+url        = http://bash-completion.alioth.debian.org/
+license    = GPLv2+
+summary    = Programmable completion for Bash.
+
+description
+       bash-completion is a collection of shell functions that take advantage
+       of the programmable completion feature of bash.
+end
+
+source_dl  = http://bash-completion.alioth.debian.org/files/
+sources    = %{thisapp}.tar.bz2
+
+build
+       install_cmds
+               rm -rvf %{BUILDROOT}%{datadir}/bash-completion/completions/{cawsay,cowthink}
+
+               install -Dpm 644 %{DIR_SOURCE}/bash-completion-1.99-redefine_filedir.bash \
+                       %{BUILDROOT}%{sysconfdir}/bash_completion.d/redefine_filedir
+       end
+end
+
+packages
+       package %{name}
+
+       requires
+               bash >= 4.1
+       end
+end
diff --git a/bash-completion/patches/bash-completion-1.99-noblacklist.patch b/bash-completion/patches/bash-completion-1.99-noblacklist.patch
new file mode 100644 (file)
index 0000000..f3cd42e
--- /dev/null
@@ -0,0 +1,12 @@
+diff -up bash-completion-1.99/bash_completion~ bash-completion-1.99/bash_completion
+--- bash-completion-1.99/bash_completion~      2012-01-08 01:03:46.000000000 +0200
++++ bash-completion-1.99/bash_completion       2012-01-08 13:50:33.412012530 +0200
+@@ -45,7 +45,7 @@ readonly BASH_COMPLETION_COMPAT_DIR
+ # Blacklisted completions, causing problems with our code.
+ #
+-_blacklist_glob='@(acroread.sh)'
++_blacklist_glob='@()' 
+ # Turn on extended globbing and programmable completion
+ shopt -s extglob progcomp