[65028] trunk/dports/sysutils/bash-completion
raimue at macports.org
raimue at macports.org
Fri Mar 19 12:00:42 PDT 2010
Revision: 65028
http://trac.macports.org/changeset/65028
Author: raimue at macports.org
Date: 2010-03-19 12:00:41 -0700 (Fri, 19 Mar 2010)
Log Message:
-----------
sysutils/bash-completion:
Lots of fixes for the port(1) completion file. Adding completion for long
options, safely passing words beginning with double dashes to port commands.
Search case-insensitive in names only for portname completion. Fix variant
completion.
The first line "# bash" tricks vim into treating this like a bash script for
syntax highlighting etc.
Modified Paths:
--------------
trunk/dports/sysutils/bash-completion/Portfile
trunk/dports/sysutils/bash-completion/files/port
Modified: trunk/dports/sysutils/bash-completion/Portfile
===================================================================
--- trunk/dports/sysutils/bash-completion/Portfile 2010-03-19 18:54:27 UTC (rev 65027)
+++ trunk/dports/sysutils/bash-completion/Portfile 2010-03-19 19:00:41 UTC (rev 65028)
@@ -4,7 +4,7 @@
name bash-completion
version 1.1
-revision 5
+revision 6
epoch 1
categories sysutils
platforms darwin
Modified: trunk/dports/sysutils/bash-completion/files/port
===================================================================
--- trunk/dports/sysutils/bash-completion/files/port 2010-03-19 18:54:27 UTC (rev 65027)
+++ trunk/dports/sysutils/bash-completion/files/port 2010-03-19 19:00:41 UTC (rev 65028)
@@ -1,3 +1,5 @@
+# bash
+
have port && {
# helper functions for port completion
#
@@ -45,12 +47,12 @@
elif [ -z "$port" ]; then
case $mode in
contents|uninstall|upgrade)
- if port -q installed "$i" | awk '{print $1}' | grep -q '^'$i'$'; then
+ if port -q installed -- "$i" | awk '{print $1}' | grep -qi '^'$i'$'; then
port=$i
fi
;;
*)
- if port -q search --exact "$i" | grep -q '^'$i'$'; then
+ if port -q search --name --exact -- "$i" | grep -qi '^'$i'$'; then
port=$i
fi
;;
@@ -64,29 +66,29 @@
case $mode in
contents|uninstall)
# installed variants
- COMPREPLY=( $( port -q installed "$port" \
- | awk '{print $2}' | tr '\r' ' ' 2>/dev/null ) )
+ COMPREPLY=( $( port -q installed -- "$port" \
+ | awk '{print $2}' | tr '\n' ' ' 2>/dev/null ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
return 0
;;
activate)
# inactive variants
- COMPREPLY=( $( port -q installed "$port" | grep -v '(active)' \
- | awk '{print $2}' | tr '\r' ' ' 2>/dev/null ) )
+ COMPREPLY=( $( port -q installed -- "$port" | grep -v '(active)' \
+ | awk '{print $2}' | tr '\n' ' ' 2>/dev/null ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
return 0
;;
deactivate)
# active variants
- COMPREPLY=( $( port -q installed "$port" | grep '(active)' \
- | awk '{print $2}' | tr '\r' ' ' 2>/dev/null ) )
+ COMPREPLY=( $( port -q installed -- "$port" | grep '(active)' \
+ | awk '{print $2}' | tr '\n' ' ' 2>/dev/null ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
return 0
;;
*)
# all variants
- COMPREPLY=( $( port -q info --line --variants "$port" | tr '\r,' ' ' ) )
- COMPREPLY=( $( compgen -P'+' -W '${COMPREPLY[@]}' -- $cur ) )
+ COMPREPLY=( $( port -q info --line --variants -- "$port" | tr '\n,' ' ' ) )
+ COMPREPLY=( $( compgen -P'+' -W '${COMPREPLY[@]}' -- ${cur/+/} ) )
return 0
;;
esac
@@ -94,52 +96,59 @@
fi
if [ -n "$mode" ]; then
- # complete port names
- case $mode in
- contents|installed|outdated|uninstall|upgrade)
- # installed ports
- COMPREPLY=( $( port -q installed "$cur*" \
- | awk '{print $1}' | uniq ) \
- $( compgen -W '${PSEUDOPORTS[@]}' -- $cur ) \
- )
- return 0
- ;;
- activate)
- # inactive ports
- COMPREPLY=( $( port -q installed "$cur*" | grep -v '(active)' \
- | awk '{print $1}' | uniq ) \
- $( compgen -W '${PSEUDOPORTS[@]}' -- $cur ) \
- )
- return 0
- ;;
- deactivate)
- # active ports
- COMPREPLY=( $( port -q installed "$cur*" | grep '(active)' \
- | awk '{print $1}' | uniq ) \
- $( compgen -W '${PSEUDOPORTS[@]}' -- $cur ) \
- )
- return 0
- ;;
- provides|cmdfile)
- _filedir
- return 0
- ;;
- portdir)
- _filedir -d
- return 0
- ;;
- selfupdate|search|sync)
- # no port
- return 0
- ;;
- *)
- # all ports
- COMPREPLY=( $( port -q search --glob "$cur*" 2>/dev/null | uniq ) \
- $( compgen -W '${PSEUDOPORTS[@]}' -- $cur ) \
- )
- return 0
- ;;
+ if [[ $cur == -* ]]; then
+ # complete options
+ COMPREPLY=( $( port -q usage -- "$mode" 2>&1 | sed 's/Usage: $mode //' ) )
+ COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
+ return 0
+ else
+ # complete port names
+ case $mode in
+ contents|installed|outdated|uninstall|upgrade)
+ # installed ports
+ COMPREPLY=( $( port -q installed -- "$cur*" \
+ | awk '{print $1}' | uniq ) \
+ $( compgen -W '${PSEUDOPORTS[@]}' -- $cur ) \
+ )
+ return 0
+ ;;
+ activate)
+ # inactive ports
+ COMPREPLY=( $( port -q installed -- "$cur*" | grep -v '(active)' \
+ | awk '{print $1}' | uniq ) \
+ $( compgen -W '${PSEUDOPORTS[@]}' -- $cur ) \
+ )
+ return 0
+ ;;
+ deactivate)
+ # active ports
+ COMPREPLY=( $( port -q installed -- "$cur*" | grep '(active)' \
+ | awk '{print $1}' | uniq ) \
+ $( compgen -W '${PSEUDOPORTS[@]}' -- $cur ) \
+ )
+ return 0
+ ;;
+ provides|cmdfile)
+ _filedir
+ return 0
+ ;;
+ portdir)
+ _filedir -d
+ return 0
+ ;;
+ selfupdate|search|sync)
+ # no port
+ return 0
+ ;;
+ *)
+ # all ports
+ COMPREPLY=( $( port -q search --name --glob -- "$cur*" 2>/dev/null | uniq ) \
+ $( compgen -W '${PSEUDOPORTS[@]}' -- $cur ) \
+ )
+ return 0
+ ;;
esac
+ fi
fi
COMPREPLY=( $( compgen -W '-b -c -d -f -k -n -o -p -q -R -s -t -u -v -y \
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100319/ddccc5d6/attachment.html>
More information about the macports-changes
mailing list