[58359] trunk/dports/sysutils/bash-completion

raimue at macports.org raimue at macports.org
Sun Sep 27 13:06:46 PDT 2009


Revision: 58359
          http://trac.macports.org/changeset/58359
Author:   raimue at macports.org
Date:     2009-09-27 13:06:43 -0700 (Sun, 27 Sep 2009)
Log Message:
-----------
sysutils/bash-completion:
Add completion for launchctl, #20553

Modified Paths:
--------------
    trunk/dports/sysutils/bash-completion/Portfile

Added Paths:
-----------
    trunk/dports/sysutils/bash-completion/files/launchctl

Modified: trunk/dports/sysutils/bash-completion/Portfile
===================================================================
--- trunk/dports/sysutils/bash-completion/Portfile	2009-09-27 20:05:05 UTC (rev 58358)
+++ trunk/dports/sysutils/bash-completion/Portfile	2009-09-27 20:06:43 UTC (rev 58359)
@@ -28,7 +28,7 @@
     xinstall -d ${destroot}${prefix}/etc/bash_completion.d
     xinstall -m 755 ${worksrcpath}/bash_completion ${destroot}${prefix}/etc/
     eval xinstall -m 644 [glob ${worksrcpath}/contrib/*] ${destroot}${prefix}/etc/bash_completion.d/
-    xinstall -m 644 ${filespath}/port ${destroot}${prefix}/etc/bash_completion.d/port
+    xinstall -m 644 -W ${filespath} port launchctl ${destroot}${prefix}/etc/bash_completion.d/
 }
 
 post-install {

Added: trunk/dports/sysutils/bash-completion/files/launchctl
===================================================================
--- trunk/dports/sysutils/bash-completion/files/launchctl	                        (rev 0)
+++ trunk/dports/sysutils/bash-completion/files/launchctl	2009-09-27 20:06:43 UTC (rev 58359)
@@ -0,0 +1,171 @@
+# ex: filetype=sh et sw=4
+#
+# launchctl(1) completion
+#
+have launchctl &&
+{
+_launchctl()
+{
+    local cur oslevel
+
+    oslevel=${OSTYPE//darwin/}
+    oslevel=${oslevel%%.*}
+
+    COMPREPLY=()
+    cur=`_get_cword`
+
+    if [[ $COMP_CWORD -eq 1 ]]; then
+        local commands
+
+        commands="load unload start stop list setenv unsetenv \
+            getenv export limit shutdown getrusage log umask help"
+
+        if [[ $oslevel -le 8 ]]; then
+            commands+=" reloadttys stdout stderr"
+        fi
+
+        if [[ $oslevel -ge 9 ]]; then
+            commands+=" submit remove bootstrap singleuser bsexec bslist"
+            if [[ $oslevel -ge 10 ]]; then
+                commands+=" bstree managerpid manageruid managername"
+            fi
+        fi
+        COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
+    else
+        local command
+        command=${COMP_WORDS[1]}
+        prev=${COMP_WORDS[COMP_CWORD-1]}
+
+        case "$command" in
+            load|unload)
+                case $prev in
+                    -S)
+                        COMPREPLY=( $( compgen -W "Aqua LoginWindow Background StandardIO System" -- $cur ) )
+                    ;;
+                    -D)
+                        COMPREPLY=( $( compgen -W "system local network all user" -- $cur ) )
+                    ;;
+                    *)
+                        opts="-w"
+                        if [[ $oslevel -ge 0 ]]; then
+                            opts+=" -S -D"
+                            if [[ $command = load ]]; then
+                                opts+=" -F"
+                            fi
+                        fi
+                        COMPREPLY=( $( compgen -f -W "$opts" -- $cur ) )
+                    ;;
+                esac
+            ;;
+            start|stop|remove|list)
+                local jobs opts
+
+                if [[ $command != list || $oslevel -ge 9 ]]; then
+                    if [[ $oslevel -le 8 ]]; then
+                        jobs="$( launchctl list )"
+                    else
+                        jobs="$( launchctl list | awk 'NR>1 { print $3 }')"
+                        if [[ $oslevel -ge 10 && $command = list ]]; then
+                            opts="-x"
+                        fi
+                    fi
+                fi
+                COMPREPLY=( $( compgen -W "$jobs $opts" -- $cur ) )
+            ;;
+            getenv|setenv|unsetenv)
+                if [[ $COMP_CWORD -eq 2 ]]; then
+                    envvars="$( launchctl export | cut -f1 -d= )"
+                    COMPREPLY=( $( compgen -W "$envvars" -- $cur ) )
+                fi
+            ;;
+            getrusage)
+                if [[ $COMP_CWORD -eq 2 ]]; then
+                    COMPREPLY=( $( compgen -W "self children" -- $cur ) )
+                fi
+            ;;
+            limit)
+                if [[ $COMP_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
+                    COMPREPLY=( $( compgen -W "level only mask" -- $cur ) )
+                else
+                    local level
+                    levels="debug info notice warning error critical alert emergency"
+                    case ${COMP_WORDS[2]} in
+                        level)
+                            if [[ $COMP_CWORD -eq 3 ]]; then
+                                COMPREPLY=( $( compgen -W "$levels" -- $cur ) )
+                            fi
+                        ;;
+                        mask|only)
+                            COMPREPLY=( $( compgen -W "$levels" -- $cur ) )
+                        ;;
+                    esac
+                fi
+            ;;
+            stdout|stderr)
+                # Darwin 8 only
+                if [[ $oslevel -le 8 ]]; then
+                    _filedir
+                fi
+            ;;
+            submit)
+                local i
+                i=1
+                while [[ $i -lt ${#COMP_WORDS[@]} ]]; do
+                    if [[ "${COMP_WORDS[i-1]}" = "--" ]]; then
+                        _command_offset $i
+                        return 0
+                    fi
+                    i=$((i+1))
+                done
+
+                local submit_opts
+                submit_opts="-l -p -o -e --"
+                case $prev in
+                    -l)
+                    ;;
+                    -p)
+                        _command_offset $COMP_CWORD
+                    ;;
+                    -o|-e)
+                        _filedir
+                    ;;
+                    *)
+                        COMPREPLY=( $( compgen -W "$submit_opts" -- $cur ) )
+                    ;;
+                esac
+
+            ;;
+            bslist)
+                local pids opts
+                pids=$( ps axo pid= )
+                [[ $oslevel -ge 10 ]] && opts="-j"
+                COMPREPLY=( $( compgen -W "$pids $opts" -- $cur ) )
+            ;;
+            bsexec)
+                if [[ $COMP_CWORD -eq 2 ]]; then
+                    local pids
+                    pids=$( ps axo pid= )
+                    COMPREPLY=( $( compgen -W "$pids" -- $cur ) )
+                else
+                    _command_offset 3
+                fi
+            ;;
+            bstree)
+                if [[ $oslevel -ge 10 ]]; then
+                    COMPREPLY=( $( compgen -W "-j" -- $cur ) )
+                fi
+                ;;
+        esac
+    fi
+
+    return 0
+}
+complete -F _launchctl $filenames launchctl
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090927/f2bd0385/attachment.html>


More information about the macports-changes mailing list