[93483] trunk/dports/sysutils/bash-completion-devel

raimue at macports.org raimue at macports.org
Wed May 23 15:10:08 PDT 2012


Revision: 93483
          https://trac.macports.org/changeset/93483
Author:   raimue at macports.org
Date:     2012-05-23 15:10:08 -0700 (Wed, 23 May 2012)
Log Message:
-----------
bash-completion-devel:
Convert local completions for port and launchctl to new format

Modified Paths:
--------------
    trunk/dports/sysutils/bash-completion-devel/Portfile
    trunk/dports/sysutils/bash-completion-devel/files/launchctl
    trunk/dports/sysutils/bash-completion-devel/files/port

Modified: trunk/dports/sysutils/bash-completion-devel/Portfile
===================================================================
--- trunk/dports/sysutils/bash-completion-devel/Portfile	2012-05-23 21:57:46 UTC (rev 93482)
+++ trunk/dports/sysutils/bash-completion-devel/Portfile	2012-05-23 22:10:08 UTC (rev 93483)
@@ -5,7 +5,7 @@
 name            bash-completion-devel
 conflicts       bash-completion
 version         1.99
-revision        1
+revision        2
 categories      sysutils
 platforms       darwin
 supported_archs noarch

Modified: trunk/dports/sysutils/bash-completion-devel/files/launchctl
===================================================================
--- trunk/dports/sysutils/bash-completion-devel/files/launchctl	2012-05-23 21:57:46 UTC (rev 93482)
+++ trunk/dports/sysutils/bash-completion-devel/files/launchctl	2012-05-23 22:10:08 UTC (rev 93483)
@@ -1,20 +1,18 @@
-# ex: filetype=sh et sw=4
-#
-# launchctl(1) completion
-#
-have launchctl &&
-{
+# launchctl(1) completion                                  -*- shell-script -*-
+
 _launchctl()
 {
-    local cur oslevel
+    local cur prev words cword
+    _init_completion || return
 
+    local oslevel
+
     oslevel=${OSTYPE//darwin/}
     oslevel=${oslevel%%.*}
 
     COMPREPLY=()
-    cur=`_get_cword`
 
-    if [[ $COMP_CWORD -eq 1 ]]; then
+    if [[ $cword -eq 1 ]]; then
         local commands
 
         commands="load unload start stop list setenv unsetenv \
@@ -33,8 +31,7 @@
         COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
     else
         local command
-        command=${COMP_WORDS[1]}
-        prev=${COMP_WORDS[COMP_CWORD-1]}
+        command=${words[1]}
 
         case "$command" in
             load|unload)
@@ -73,32 +70,32 @@
                 COMPREPLY=( $( compgen -W "$jobs $opts" -- $cur ) )
             ;;
             getenv|setenv|unsetenv)
-                if [[ $COMP_CWORD -eq 2 ]]; then
+                if [[ $cword -eq 2 ]]; then
                     envvars="$( launchctl export | cut -f1 -d= )"
                     COMPREPLY=( $( compgen -W "$envvars" -- $cur ) )
                 fi
             ;;
             getrusage)
-                if [[ $COMP_CWORD -eq 2 ]]; then
+                if [[ $cword -eq 2 ]]; then
                     COMPREPLY=( $( compgen -W "self children" -- $cur ) )
                 fi
             ;;
             limit)
-                if [[ $COMP_CWORD -eq 2 ]]; then
+                if [[ $cword -eq 2 ]]; then
                     local limits
                     limits="$( launchctl limit | awk '{print $1}' )"
                     COMPREPLY=( $( compgen -W "$limits" -- $cur ) )
                 fi
             ;;
             log)
-                if [[ $COMP_CWORD -eq 2 ]]; then
+                if [[ $cword -eq 2 ]]; then
                     COMPREPLY=( $( compgen -W "level only mask" -- $cur ) )
                 else
                     local level
                     levels="debug info notice warning error critical alert emergency"
-                    case ${COMP_WORDS[2]} in
+                    case ${words[2]} in
                         level)
-                            if [[ $COMP_CWORD -eq 3 ]]; then
+                            if [[ $cword -eq 3 ]]; then
                                 COMPREPLY=( $( compgen -W "$levels" -- $cur ) )
                             fi
                         ;;
@@ -117,8 +114,8 @@
             submit)
                 local i
                 i=1
-                while [[ $i -lt ${#COMP_WORDS[@]} ]]; do
-                    if [[ "${COMP_WORDS[i-1]}" = "--" ]]; then
+                while [[ $i -lt ${#words[@]} ]]; do
+                    if [[ "${words[i-1]}" = "--" ]]; then
                         _command_offset $i
                         return 0
                     fi
@@ -131,7 +128,7 @@
                     -l)
                     ;;
                     -p)
-                        _command_offset $COMP_CWORD
+                        _command_offset $cword
                     ;;
                     -o|-e)
                         _filedir
@@ -149,7 +146,7 @@
                 COMPREPLY=( $( compgen -W "$pids $opts" -- $cur ) )
             ;;
             bsexec)
-                if [[ $COMP_CWORD -eq 2 ]]; then
+                if [[ $cword -eq 2 ]]; then
                     local pids
                     pids=$( ps axo pid= )
                     COMPREPLY=( $( compgen -W "$pids" -- $cur ) )
@@ -166,6 +163,7 @@
     fi
 
     return 0
-}
-complete -F _launchctl $filenames launchctl
-}
+} &&
+complete -F _launchctl launchctl
+
+# ex: ts=4 sw=4 et filetype=sh

Modified: trunk/dports/sysutils/bash-completion-devel/files/port
===================================================================
--- trunk/dports/sysutils/bash-completion-devel/files/port	2012-05-23 21:57:46 UTC (rev 93482)
+++ trunk/dports/sysutils/bash-completion-devel/files/port	2012-05-23 22:10:08 UTC (rev 93483)
@@ -1,39 +1,34 @@
-# bash
+# port(1) completion                                       -*- shell-script -*-
 
-have port && {
-# helper functions for port completion
-#
-
-# port(1) completion
-# 
 _port()
 {
-        local cur prev mode count portdir cmdfile i port PSEUDOPORTS
+        local cur prev words cword
+        _init_completion || return
 
+        local mode count portdir cmdfile i port PSEUDOPORTS
+
         PSEUDOPORTS=( all current active inactive installed uninstalled
                       outdated obsolete requested unrequested leaves )
 
         COMPREPLY=()
-        cur=${COMP_WORDS[COMP_CWORD]}
-        prev=${COMP_WORDS[COMP_CWORD-1]}
 
         count=0
-        for i in ${COMP_WORDS[@]}; do
-            [ $count -eq $COMP_CWORD ] && break
+        for i in ${words[@]}; do
+            [ $count -eq $cword ] && break
             # Last parameter was a required parameter, now go back to mode selection
-            if [ "${COMP_WORDS[((count))]}" == "$portdir" -a "$mode" == "portdir" ] \
-                    || [ "${COMP_WORDS[((count))]}" == "$cmdfile" -a "$mode" == "cmdfile" ]; then
+            if [ "${words[((count))]}" == "$portdir" -a "$mode" == "portdir" ] \
+                    || [ "${words[((count))]}" == "$cmdfile" -a "$mode" == "cmdfile" ]; then
                 mode=""
             fi
             if [ -z "$mode" ]; then
                 case $i in
                     -D)
                         mode=portdir
-                        portdir=${COMP_WORDS[((count+1))]}
+                        portdir=${words[((count+1))]}
                         ;;
                     -F)
                         mode=cmdfile
-                        cmdfile=${COMP_WORDS[((count+1))]}
+                        cmdfile=${words[((count+1))]}
                         ;;
                     activate|archive|archivefetch|build|cat|cd|checksum|clean|configure|\
                         contents|deactivate|dependents|deps|destroot|dir|distcheck|distfiles|\
@@ -165,6 +160,7 @@
                                 setrequested space srpm submit sync test unarchive uninstall \
                                 unload unsetrequested upgrade url usage variants version work' -- $cur ) )
         return 0
-}
-complete -F _port $filenames port
-}
+} &&
+complete -F _port port
+
+# ex: ts=4 sw=4 et filetype=sh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120523/2e6a47f0/attachment.html>


More information about the macports-changes mailing list