# HG changeset patch # User Stefan Teleman # Date 1298743407 28800 # Node ID 77641682ba6fd4ddaa5f19f3db1e0de71248e3ab # Parent 07cc6a1a08ad8d6aee00144f8c33aa056eaff008 7015638 bash needs to move to userland diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/Makefile Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,154 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +# +include ../../make-rules/shared-macros.mk + +COMPONENT_NAME= bash +COMPONENT_VERSION= 4.1 +COMPONENT_SRC= $(COMPONENT_NAME)-$(COMPONENT_VERSION) +COMPONENT_PROJECT_URL= http://www.gnu.org/software/bash/ +COMPONENT_ARCHIVE= $(COMPONENT_SRC).tar.gz +COMPONENT_ARCHIVE_HASH= sha1:3bd1ec9c66f3689f6b3495bdaaf9077b2e5dc150 +COMPONENT_ARCHIVE_URL= http://ftp.gnu.org/gnu/bash/$(COMPONENT_ARCHIVE) + +include ../../make-rules/prep.mk +include ../../make-rules/configure.mk +include ../../make-rules/ips.mk + +IPS_COMPONENT_VERSION = $(COMPONENT_VERSION).9 +PATCH_LEVEL = 0 + + +# Enable C99 mode + -Xc for it's additional warnings. +studio_C99MODE = -Xc $(studio_C99_ENABLE) + +# Use the maximum number of registers on sparc since we have no libraries +studio_XREGS.sparc = -xregs=appl + +# 8 byte memory alignment + interpretation of non-alignment instead of SIGBUS +studio_ALIGN.sparc.32 = -xmemalign=8i + +# -xinline=%auto -- we like inlining where appropriate +CFLAGS += -xinline=%auto + +# -xbuiltin=%none -- builtins have been known to be buggy +CFLAGS += -xbuiltin=%none + +CFLAGS += $(XPG6MODE) +CFLAGS += $(CPP_POSIX) +CFLAGS += $(CPP_C99_EXTENDED_MATH) + +# configure checks for some functions, but doesn't seem to want to link in +# the required libraries for them. We avoid linking with libthread.so.1 +# just because we pass -mt, by explicitly passing -lc. +LIBS = -lc -lsocket -lgen + +# -z redlocsym -- let's shrink the SHT_SYMTAB as much as we can +LDFLAGS = $(LD_Z_REDLOCSYM) + +# The bash test harness needs the GNU userland utilities +TEST_PATH = "PATH=$(BUILD_DIR_32):$(GNUBIN):$(USRBINDIR)" +TEST_OUTPUT = $(COMPONENT_DIR)/bash_test_results_$(MACH).out + +CONFIGURE_ENV += CFLAGS="$(CFLAGS)" +CONFIGURE_ENV += LDFLAGS="$(LDFLAGS)" +CONFIGURE_ENV += LIBS="$(LIBS)" + +CONFIGURE_OPTIONS += --localstatedir=/var +CONFIGURE_OPTIONS += --enable-alias +CONFIGURE_OPTIONS += --enable-arith-for-command +CONFIGURE_OPTIONS += --enable-array-variables +CONFIGURE_OPTIONS += --enable-bang-history +CONFIGURE_OPTIONS += --enable-brace-expansion +CONFIGURE_OPTIONS += --enable-casemod-attributes +CONFIGURE_OPTIONS += --enable-casemod-expansions +CONFIGURE_OPTIONS += --enable-command-timing +CONFIGURE_OPTIONS += --enable-cond-command +CONFIGURE_OPTIONS += --enable-cond-regexp +CONFIGURE_OPTIONS += --enable-coprocesses +CONFIGURE_OPTIONS += --enable-debugger +CONFIGURE_OPTIONS += --enable-directory-stack +CONFIGURE_OPTIONS += --enable-disabled-builtins +CONFIGURE_OPTIONS += --enable-dparen-arithmetic +CONFIGURE_OPTIONS += --enable-extended-glob +CONFIGURE_OPTIONS += --enable-help-builtin +CONFIGURE_OPTIONS += --enable-history +CONFIGURE_OPTIONS += --enable-job-control +CONFIGURE_OPTIONS += --enable-multibyte +CONFIGURE_OPTIONS += --enable-net-redirections +CONFIGURE_OPTIONS += --enable-process-substitution +CONFIGURE_OPTIONS += --enable-progcomp +CONFIGURE_OPTIONS += --enable-prompt-string-decoding +CONFIGURE_OPTIONS += --enable-readline +CONFIGURE_OPTIONS += --enable-restricted +CONFIGURE_OPTIONS += --enable-select +CONFIGURE_OPTIONS += --enable-separate-helpfiles +CONFIGURE_OPTIONS += --enable-single-help-strings +CONFIGURE_OPTIONS += --disable-strict-posix-default +CONFIGURE_OPTIONS += --enable-usg-echo-default +CONFIGURE_OPTIONS += --enable-xpg-echo-default +CONFIGURE_OPTIONS += --enable-mem-scramble +CONFIGURE_OPTIONS += --disable-profiling +CONFIGURE_OPTIONS += --enable-static-link +CONFIGURE_OPTIONS += --enable-largefile +CONFIGURE_OPTIONS += --enable-nls +CONFIGURE_OPTIONS += --with-bash-malloc +CONFIGURE_OPTIONS += --with-curses +CONFIGURE_OPTIONS += --with-installed-readline=no +CONFIGURE_OPTIONS += --infodir=$(CONFIGURE_INFODIR) + +build: $(BUILD_32) + +install: $(INSTALL_32) + ( mkdir -p $(PROTO_DIR)/etc/bash/bash_completion.d ; \ + cp -p $(COMPONENT_DIR)/Solaris/etc.bash.bash_completion \ + $(PROTO_DIR)/etc/bash/bash_completion.example ; \ + cp -p $(COMPONENT_DIR)/Solaris/etc.bash.bashrc \ + $(PROTO_DIR)/etc/bash/bashrc.example ; \ + cp -p $(COMPONENT_DIR)/Solaris/etc.bash.inputrc \ + $(PROTO_DIR)/etc/bash/inputrc.example ; \ + cp -p $(COMPONENT_DIR)/Solaris/rbash.1 \ + $(PROTOUSRSHAREMAN1DIR)/ ) + ( cd $(PROTOUSRSHAREDIR)/locale ; \ + cp -Rp "en@boldquot" en ; \ + cp -Rp "en@boldquot" en_CA ; \ + cp -Rp "en@boldquot" en_GB ) + sed -f oracleman-stability $(PROTOUSRSHAREMAN1DIR)/bash.1 > \ + $(PROTOUSRSHAREMAN1DIR)/bash.1.sed + cp -fp $(PROTOUSRSHAREMAN1DIR)/bash.1.sed \ + $(PROTOUSRSHAREMAN1DIR)/bash.1 + sed -f oracleman-stability $(PROTOUSRSHAREMAN1DIR)/rbash.1 > \ + $(PROTOUSRSHAREMAN1DIR)/rbash.1.sed + cp -fp $(PROTOUSRSHAREMAN1DIR)/rbash.1.sed \ + $(PROTOUSRSHAREMAN1DIR)/rbash.1 + rm -f $(PROTOUSRSHAREMAN1DIR)/bash.1.sed \ + $(PROTOUSRSHAREMAN1DIR)/rbash.1.sed + +test: $(BUILD_32) + ( cd $(BUILD_DIR_32) ; \ + env - $(TEST_PATH) $(TARGET_ENV) $(GMAKE) check > \ + $(TEST_OUTPUT) 2>&1 ) + +BUILD_PKG_DEPENDENCIES = $(BUILD_TOOLS) + +include ../../make-rules/depend.mk + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/SUNWbash.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/SUNWbash.p5m Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,31 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +# + +# +# Legacy package information for renamed SUNWbash package +# + +set name=pkg.fmri value=pkg://solaris/SUNWbash@4.0.28,5.11-0.133 +set name=pkg.renamed value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) +depend fmri=shell/bash@4.0.28-0.133 type=require diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/Solaris/etc.bash.bash_completion --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/Solaris/etc.bash.bash_completion Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,9417 @@ +# +# This file contains an example set of shell completions that can be used with +# bash(1). These completions allow a user to complete filenames, commands +# name, command line options, and command line arguments using the [tab] key. +# The completions defined here are specific to the GNU command set, as a result +# they will provide the choice of GNU command line options in response to the +# [tab] key. For the completed options to match the command implementation, +# you may have to have /usr/gnu/bin at the head of your PATH. +# +# These completions are not included in the default bash(1) environment. To +# include them in the default environment, it is recommended that this file be +# copied to /etc/bash/bash_completion and be sourced from either a system wide +# bashrc in /etc/bash/bashrc or individual bashrcs in ~/.bashrc via +# [ -f /etc/bash/bash_completion ] && . /etc/bash/bash_completion +# + +# bash_completion - programmable completion functions for bash 3.x +# (backwards compatible with bash 2.05b) +# +# $Id: bash_completion,v 1.872 2006/03/01 16:20:18 ianmacd Exp $ +# +# Copyright (C) Ian Macdonald +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The latest version of this software can be obtained here: +# +# http://www.caliban.org/bash/index.shtml#completion +# +# RELEASE: 20060301 + +if [[ $- == *v* ]]; then + BASH_COMPLETION_ORIGINAL_V_VALUE="-v" +else + BASH_COMPLETION_ORIGINAL_V_VALUE="+v" +fi + +if [[ -n $BASH_COMPLETION_DEBUG ]]; then + set -v +else + set +v +fi + +# Alter the following to reflect the location of this file. +# +[ -n "$BASH_COMPLETION" ] || BASH_COMPLETION=/etc/bash/bash_completion +[ -n "$BASH_COMPLETION_DIR" ] || BASH_COMPLETION_DIR=/etc/bash/bash_completion.d +readonly BASH_COMPLETION BASH_COMPLETION_DIR + +# Set a couple of useful vars +# +UNAME=$( uname -s ) +# strip OS type and version under Cygwin (e.g. CYGWIN_NT-5.1 => Cygwin) +UNAME=${UNAME/CYGWIN_*/Cygwin} +RELEASE=$( uname -r ) + +# features supported by bash 2.05 and higher +if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} > 04 ]] || + [ ${BASH_VERSINFO[0]} -gt 2 ]; then + declare -r bash205=$BASH_VERSION 2>/dev/null || : + default="-o default" + dirnames="-o dirnames" + filenames="-o filenames" +fi +# features supported by bash 2.05b and higher +if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] || + [ ${BASH_VERSINFO[0]} -gt 2 ]; then + declare -r bash205b=$BASH_VERSION 2>/dev/null || : + nospace="-o nospace" +fi +# features supported by bash 3.0 and higher +if [ ${BASH_VERSINFO[0]} -gt 2 ]; then + declare -r bash3=$BASH_VERSION 2>/dev/null || : + bashdefault="-o bashdefault" + plusdirs="-o plusdirs" +fi + +# Turn on extended globbing and programmable completion +shopt -s extglob progcomp + +# A lot of the following one-liners were taken directly from the +# completion examples provided with the bash 2.04 source distribution + +# Make directory commands see only directories +complete -d pushd + +# The following section lists completions that are redefined later +# Do NOT break these over multiple lines. +# +# START exclude -- do NOT remove this line +complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep +complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|ott)' unzip zipinfo +complete -f -X '*.Z' compress znew +complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcmp zdiff zcat zegrep zfgrep zgrep zless zmore +complete -f -X '!*.Z' uncompress +complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' ee display +complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv +complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview +complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi +complete -f -X '!*.@(dvi|DVI)?(.@(gz|bz2))' kdvi +complete -f -X '!*.@(dvi|DVI)' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx +complete -f -X '!*.@(pdf|PDF)' acroread gpdf xpdf +complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' kpdf +complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ)|cb(r|z)|CB(R|Z)|djv?(u)|DJV?(U)||dvi|DVI|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' evince +complete -f -X '!*.@(?(e)ps|?(E)PS)' ps2pdf +complete -f -X '!*.texi*' makeinfo texi2html +complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi +complete -f -X '!*.@(mp3|MP3)' mpg123 mpg321 madplay +complete -f -X '!*.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp3|MP3|m4v|M4V|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV|asx|ASX|mng|MNG|srt)' xine aaxine fbxine kaffeine +complete -f -X '!*.@(avi|asf|wmv)' aviplay +complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay +complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim +complete -f -X '!*.@(ogg|OGG|m3u|flac|spx)' ogg123 +complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp +complete -f -X '!*.fig' xfig +complete -f -X '!*.@(mid?(i)|MID?(I))' playmidi +complete -f -X '!*.@(mid?(i)|MID?(I)|rmi|RMI|rcp|RCP|[gr]36|[GR]36|g18|G18|mod|MOD|xm|XM|it|IT|x3m|X3M)' timidity +complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' vi vim gvim rvim view rview rgvim rgview gview +complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' emacs +complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR|exe.so)' wine +complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme +complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon curl dillo elinks amaya +complete -f -X '!*.@(sxw|stw|sxg|sgl|doc|dot|rtf|txt|htm|html|odt|ott|odm)' oowriter +complete -f -X '!*.@(sxi|sti|pps|ppt|pot|odp|otp)' ooimpress +complete -f -X '!*.@(sxc|stc|xls|xlw|xlt|csv|ods|ots)' oocalc +complete -f -X '!*.@(sxd|std|sda|sdd|odg|otg)' oodraw +complete -f -X '!*.@(sxm|smf|mml|odf)' oomath +complete -f -X '!*.odb' oobase +complete -f -X '!*.rpm' rpm2cpio +# FINISH exclude -- do not remove this line + +# start of section containing compspecs that can be handled within bash + +# user commands see only users +complete -u su usermod userdel passwd chage write chfn groups slay w sux + +# group commands see only groups +[ -n "$bash205" ] && complete -g groupmod groupdel newgrp 2>/dev/null + +# bg completes with stopped jobs +complete -A stopped -P '%' bg + +# other job commands +complete -j -P '%' fg jobs disown + +# readonly and unset complete with shell variables +complete -v readonly unset + +# set completes with set options +complete -A setopt set + +# shopt completes with shopt options +complete -A shopt shopt + +# helptopics +complete -A helptopic help + +# unalias completes with aliases +complete -a unalias + +# bind completes with readline bindings (make this more intelligent) +complete -A binding bind + +# type and which complete on commands +complete -c command type which + +# builtin completes on builtins +complete -b builtin + +# start of section containing completion functions called by other functions + +# This function checks whether we have a given program on the system. +# No need for bulky functions in memory if we don't. +# +have() +{ + unset -v have + PATH=/usr/gnu/bin:$PATH:/sbin:/usr/sbin type $1 &>/dev/null && + have="yes" +} + +# use GNU sed if we have it, since its extensions are still used in our code +# +[ $UNAME != Linux ] && have gsed && alias sed=gsed + +# This function checks whether a given readline variable +# is `on'. +# +_rl_enabled() +{ + [[ "$( bind -v )" = *$1+([[:space:]])on* ]] +} + +# This function shell-quotes the argument +quote() +{ + echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting +} + +# This function quotes the argument in a way so that readline dequoting +# results in the original argument +quote_readline() +{ + local t="${1//\\/\\\\}" + echo \'${t//\'/\'\\\'\'}\' #'# Help vim syntax highlighting +} + +# This function shell-dequotes the argument +dequote() +{ + eval echo "$1" +} + + +# Get the word to complete +# This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases +# where the user is completing in the middle of a word. +# (For example, if the line is "ls foobar", +# and the cursor is here --------> ^ +# it will complete just "foo", not "foobar", which is what the user wants.) +_get_cword() +{ + if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then + echo "${COMP_WORDS[COMP_CWORD]}" + else + local i + local cur="$COMP_LINE" + local index="$COMP_POINT" + for (( i = 0; i <= COMP_CWORD; ++i )); do + while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do + cur="${cur:1}" + index="$(( index - 1 ))" + done + if [[ "$i" -lt "$COMP_CWORD" ]]; then + local old_size="${#cur}" + cur="${cur#${COMP_WORDS[i]}}" + local new_size="${#cur}" + index="$(( index - old_size + new_size ))" + fi + done + + if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then + # We messed up! At least return the whole word so things keep working + echo "${COMP_WORDS[COMP_CWORD]}" + else + echo "${cur:0:$index}" + fi + fi +} + + +# This function performs file and directory completion. It's better than +# simply using 'compgen -f', because it honours spaces in filenames. +# If passed -d, it completes only on directories. If passed anything else, +# it's assumed to be a file glob to complete on. +# +_filedir() +{ + local IFS=$'\t\n' xspec + + _expand || return 0 + + local toks=( ) tmp + while read -r tmp; do + [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp + done < <( compgen -d -- "$(quote_readline "$cur")" ) + + if [[ "$1" != -d ]]; then + xspec=${1:+"!*.$1"} + while read -r tmp; do + [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp + done < <( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" ) + fi + + COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" ) +} + +# This function completes on signal names +# +_signals() +{ + local i + + # standard signal completion is rather braindead, so we need + # to hack around to get what we want here, which is to + # complete on a dash, followed by the signal name minus + # the SIG prefix + COMPREPLY=( $( compgen -A signal SIG${cur#-} )) + for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do + COMPREPLY[i]=-${COMPREPLY[i]#SIG} + done +} + +# This function completes on configured network interfaces +# +_configured_interfaces() +{ + if [ -f /etc/debian_version ]; then + # Debian system + COMPREPLY=( $( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' \ + /etc/network/interfaces ) ) + elif [ -f /etc/SuSE-release ]; then + # SuSE system + COMPREPLY=( $( command ls \ + /etc/sysconfig/network/ifcfg-* | \ + sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) ) + elif [ -f /etc/pld-release ]; then + # PLD Linux + COMPREPLY=( $( command ls -B \ + /etc/sysconfig/interfaces | \ + sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) ) + else + # Assume Red Hat + COMPREPLY=( $( command ls \ + /etc/sysconfig/network-scripts/ifcfg-* | \ + sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) ) + fi +} + +# This function completes on all available network interfaces +# -a: restrict to active interfaces only +# -w: restrict to wireless interfaces only +# +_available_interfaces() +{ + local cmd + + if [ "${1:-}" = -w ]; then + cmd="iwconfig" + elif [ "${1:-}" = -a ]; then + cmd="ifconfig" + else + cmd="ifconfig -a" + fi + + COMPREPLY=( $( eval $cmd 2>/dev/null | \ + sed -ne 's|^\('$cur'[^[:space:][:punct:]]\{1,\}\).*$|\1|p') ) +} + +# This function expands tildes in pathnames +# +_expand() +{ + # FIXME: Why was this here? + # [ "$cur" != "${cur%\\}" ] && cur="$cur\\" + + # expand ~username type directory specifications + if [[ "$cur" == \~*/* ]]; then + eval cur=$cur + elif [[ "$cur" == \~* ]]; then + cur=${cur#\~} + COMPREPLY=( $( compgen -P '~' -u $cur ) ) + return ${#COMPREPLY[@]} + fi +} + +# This function completes on process IDs. +# AIX and Solaris ps prefers X/Open syntax. +[ $UNAME = SunOS -o $UNAME = AIX ] && +_pids() +{ + COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- $cur )) +} || +_pids() +{ + COMPREPLY=( $( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ) ) +} + +# This function completes on process group IDs. +# AIX and SunOS prefer X/Open, all else should be BSD. +[ $UNAME = SunOS -o $UNAME = AIX ] && +_pgids() +{ + COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- $cur )) +} || +_pgids() +{ + COMPREPLY=( $( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur )) +} + +# This function completes on user IDs +# +_uids() +{ + if type getent &>/dev/null; then + COMPREPLY=( $( getent passwd | \ + awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) ) + elif type perl &>/dev/null; then + COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- $cur ) ) + else + # make do with /etc/passwd + COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\ + /etc/passwd ) ) + fi +} + +# This function completes on group IDs +# +_gids() +{ + if type getent &>/dev/null; then + COMPREPLY=( $( getent group | \ + awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) ) + elif type perl &>/dev/null; then + COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- $cur ) ) + else + # make do with /etc/group + COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\ + /etc/group ) ) + fi +} + +# This function completes on services +# +_services() +{ + local sysvdir famdir + [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d + famdir=/etc/xinetd.d + COMPREPLY=( $( builtin echo $sysvdir/!(*.rpmsave|*.rpmorig|*~|functions)) ) + + if [ -d $famdir ]; then + COMPREPLY=( "${COMPREPLY[@]}" $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) ) + fi + + COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ) ) +} + +# This function complete on modules +# +_modules() +{ + local modpath + modpath=/lib/modules/$1 + COMPREPLY=( $( command ls -R $modpath | \ + sed -ne 's/^\('$cur'.*\)\.k\?o\(\|.gz\)$/\1/p') ) +} + +# this function complete on user:group format +# +_usergroup() +{ + local IFS=$'\n' + cur=${cur//\\\\ / } + if [[ $cur = *@(\\:|.)* ]] && [ -n "$bash205" ]; then + user=${cur%%*([^:.])} + COMPREPLY=( $(compgen -P ${user/\\\\} -g -- ${cur##*[.:]}) ) + elif [[ $cur = *:* ]] && [ -n "$bash205" ]; then + COMPREPLY=( $( compgen -g -- ${cur##*[.:]} ) ) + else + COMPREPLY=( $( compgen -S : -u -- $cur ) ) + fi +} + +# this function count the number of mandatory args +# +_count_args() +{ + args=1 + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" != -* ]]; then + args=$(($args+1)) + fi + done +} + +# start of section containing completion functions for bash built-ins + +# bash alias completion +# +_alias() +{ + local cur + + COMPREPLY=() + cur=${COMP_WORDS[$COMP_CWORD]} + + case "$COMP_LINE" in + *[^=]) + COMPREPLY=( $( compgen -A alias -S '=' -- $cur ) ) + ;; + *=) + COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | \ + sed -e 's|^alias '$cur'\(.*\)$|\1|' )" ) + ;; + esac +} +complete -F _alias $nospace alias + +# bash export completion +# +_export() +{ + local cur + + COMPREPLY=() + cur=${COMP_WORDS[$COMP_CWORD]} + + case "$COMP_LINE" in + *=\$*) + COMPREPLY=( $( compgen -v -P '$' -- ${cur#*=\$} ) ) + ;; + *[^=]) + COMPREPLY=( $( compgen -v -S '=' -- $cur ) ) + ;; + *=) + COMPREPLY=( "$( eval echo -n \"$`echo ${cur%=}`\" | + ( echo -n \' + sed -e 's/'\''/'\''\\\'\'''\''/g' + echo -n \' ) )" ) + ;; + esac +} +complete -F _export $default $nospace export + +# bash shell function completion +# +_function() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [[ $1 == @(declare|typeset) ]]; then + if [ "$prev" = -f ]; then + COMPREPLY=( $( compgen -A function -- $cur ) ) + elif [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- \ + $cur ) ) + fi + elif [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -A function -- $cur ) ) + else + COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" ) + fi +} +complete -F _function function declare typeset + +# bash complete completion +# +_complete() +{ + local cur prev options + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + -o) + options="default dirnames filenames" + [ -n "$bash205b" ] && options="$options nospace" + [ -n "$bash3" ] && options="$options bashdefault plusdirs" + COMPREPLY=( $( compgen -W "$options" -- $cur ) ) + return 0 + ;; + + -A) + COMPREPLY=( $( compgen -W 'alias arrayvar binding \ + builtin command directory disabled enabled \ + export file function group helptopic hostname \ + job keyword running service setopt shopt \ + signal stopped user variable' -- $cur ) ) + return 0 + ;; + + -C) + COMPREPLY=( $( compgen -A command -- $cur ) ) + return 0 + ;; + -F) + COMPREPLY=( $( compgen -A function -- $cur ) ) + return 0 + ;; + -@(p|r)) + COMPREPLY=( $( complete -p | sed -e 's|.* ||' | \ + grep "^$cur" ) ) + return 0 + ;; + + esac + + if [[ "$cur" == -* ]]; then + # relevant options completion + options="-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C" + [ -n "$bash205" ] && options="$options -o" + COMPREPLY=( $( compgen -W "$options" -- $cur ) ) + else + COMPREPLY=( $( compgen -A command -- $cur ) ) + fi +} +complete -F _complete complete + +# start of section containing completion functions for external programs + +# a little help for FreeBSD ports users +[ $UNAME = FreeBSD ] && complete -W 'index search fetch fetch-list \ + extract patch configure build install reinstall \ + deinstall clean clean-depends kernel buildworld' make + +# This completes on a list of all available service scripts for the +# 'service' command and/or the SysV init.d directory, followed by +# that script's available commands +# +{ have service || [ -d /etc/init.d/ ]; } && +_service() +{ + local cur sysvdir + + COMPREPLY=() + prev=${COMP_WORDS[COMP_CWORD-1]} + cur=`_get_cword` + + # don't complete for things like killall, ssh and mysql if it's + # the standalone command, rather than the init script + [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0 + + # don't complete past 2nd token + [ $COMP_CWORD -gt 2 ] && return 0 + + [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \ + || sysvdir=/etc/init.d + + if [[ $COMP_CWORD -eq 1 ]] && [[ $prev == "service" ]]; then + _services + else + COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \ + s/^.*Usage.*{\(.*\)}.*$/\1/p" \ + $sysvdir/${prev##*/} 2>/dev/null`' -- $cur ) ) + fi + + return 0 +} && +complete -F _service service +[ -d /etc/init.d/ ] && complete -F _service $default \ + $(for i in /etc/init.d/*; do echo ${i##*/}; done) + +# chown(1) completion +# +_chown() +{ + local cur + cur=`_get_cword` + + # options completion + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \ + --dereference --no-dereference --from= --silent --quiet \ + --reference= --recursive --verbose --help --version' -- $cur ) ) + else + _count_args + + case $args in + 1) + _usergroup + ;; + *) + _filedir + ;; + esac + fi +} +complete -F _chown $filenames chown + +# chgrp(1) completion +# +_chgrp() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + cur=${cur//\\\\/} + prev=${COMP_WORDS[COMP_CWORD-1]} + + # options completion + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \ + --dereference --no-dereference --silent --quiet \ + --reference= --recursive --verbose --help --version' -- $cur ) ) + return 0 + fi + + # first parameter on line or first since an option? + if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || \ + [[ "$prev" == -* ]] && [ -n "$bash205" ]; then + local IFS=$'\n' + COMPREPLY=( $( compgen -g $cur 2>/dev/null ) ) + else + _filedir || return 0 + fi + + return 0 +} +complete -F _chgrp $filenames chgrp + +# umount(8) completion. This relies on the mount point being the third +# space-delimited field in the output of mount(8) +# +_umount() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + OLDIFS="$IFS" + IFS="\n" + COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- $cur ) ) + IFS="$OLDIFS" + + return 0 +} +complete -F _umount $dirnames umount + +# mount(8) completion. This will pull a list of possible mounts out of +# /etc/{,v}fstab, unless the word being completed contains a ':', which +# would indicate the specification of an NFS server. In that case, we +# query the server for a list of all available exports and complete on +# that instead. +# +_mount() +{ local cur i sm host + + COMPREPLY=() + cur=`_get_cword` + [[ "$cur" == \\ ]] && cur="/" + + for i in {,/usr}/{,s}bin/showmount; do [ -x $i ] && sm=$i && break; done + + if [ -n "$sm" ] && [[ "$cur" == *:* ]]; then + COMPREPLY=( $( $sm -e ${cur%%:*} | sed 1d | \ + grep ^${cur#*:} | awk '{print $1}' ) ) + elif [[ "$cur" == //* ]]; then + host=${cur#//} + host=${host%%/*} + if [ -n "$host" ]; then + COMPREPLY=( $( compgen -W "$( echo $( smbclient -d 0 -NL $host 2>/dev/null| + sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' | + sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|//'$host'/\1|p' ) )" -- "$cur" ) ) + fi + elif [ -r /etc/vfstab ]; then + # Solaris + COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \ + /etc/vfstab | grep "^$cur" ) ) + elif [ ! -e /etc/fstab ]; then + # probably Cygwin + COMPREPLY=( $( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \ + | grep "^$cur" ) ) + else + # probably Linux + COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \ + /etc/fstab | grep "^$cur" ) ) + fi + + return 0 +} +complete -F _mount $default $filenames mount + +# Linux rmmod(8) completion. This completes on a list of all currently +# installed kernel modules. +# +have rmmod && { +_rmmod() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + COMPREPLY=( $( /sbin/lsmod | \ + awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' 2>/dev/null )) + return 0 +} +complete -F _rmmod rmmod + +# Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a +# list of all available modules for the version of the kernel currently +# running. +# +_insmod() +{ + local cur prev modpath + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + # behave like lsmod for modprobe -r + if [ $1 = "modprobe" ] && + [ "${COMP_WORDS[1]}" = "-r" ]; then + COMPREPLY=( $( /sbin/lsmod | \ + awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' ) ) + return 0 + fi + + # do filename completion if we're giving a path to a module + if [[ "$cur" == */* ]]; then + _filedir '@(?(k)o?(.gz))' + return 0 + fi + + if [ $COMP_CWORD -gt 1 ] && + [[ "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then + # do module parameter completion + COMPREPLY=( $( /sbin/modinfo -p ${COMP_WORDS[1]} 2>/dev/null | \ + awk '{if ($1 ~ /^parm:/ && $2 ~ /^'$cur'/) { print $2 } \ + else if ($1 !~ /:/ && $1 ~ /^'$cur'/) { print $1 }}' ) ) + else + _modules $(uname -r) + fi + + return 0 +} +complete -F _insmod $filenames insmod modprobe modinfo +} + +# man(1) completion +# +[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \ + -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \ + -o $UNAME = OpenBSD ] && +_man() +{ + local cur prev sect manpath UNAME + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + _expand || return 0 + + # default completion if parameter contains / + if [[ "$cur" == */* ]]; then + _filedir + return 0 + fi + + UNAME=$( uname -s ) + # strip OS type and version under Cygwin + UNAME=${UNAME/CYGWIN_*/Cygwin} + if [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = FreeBSD \ + -o $UNAME = Cygwin ]; then + manpath=$( manpath 2>/dev/null || command man --path ) + else + manpath=$MANPATH + fi + + if [ -z "$manpath" ]; then + COMPREPLY=( $( compgen -c -- $cur ) ) + return 0 + fi + + # determine manual section to search + [[ "$prev" == [0-9ln] ]] && sect=$prev || sect='*' + + manpath=$manpath: + if [ -n "$cur" ]; then + manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }" + else + manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }" + fi + + # redirect stderr for when path doesn't exist + COMPREPLY=( $( eval command ls "$manpath" 2>/dev/null ) ) + # weed out directory path names and paths to man pages + COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) + # strip suffix from man pages + COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) ) + + [[ "$prev" != [0-9ln] ]] && _filedir '[0-9ln]' + + return 0 +} +[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \ + -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \ + -o $UNAME = OpenBSD ] && \ +complete -F _man $filenames man apropos whatis + +# renice(8) completion +# +_renice() +{ + local command cur curopt i + + COMPREPLY=() + cur=`_get_cword` + command=$1 + + i=0 + # walk back through command line and find last option + while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do + curopt=${COMP_WORDS[COMP_CWORD-$i]} + case "$curopt" in + -u) + COMPREPLY=( $( compgen -u -- $cur ) ) + ;; + -g) + _pgids + ;; + -p|$command) + _pids + ;; + esac + i=$(( ++i )) + done +} +complete -F _renice renice + +# kill(1) completion +# +_kill() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then + # return list of available signals + _signals + else + # return list of available PIDs + _pids + fi +} +complete -F _kill kill + +# Linux and FreeBSD killall(1) completion. +# +[ $UNAME = Linux -o $UNAME = FreeBSD ] && +_killall() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then + _signals + else + COMPREPLY=( $( compgen -W '$( command ps axo command | \ + sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \ + sed -e "s/.*\///" )' -- $cur ) ) + fi + + return 0 +} +[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall pkill + +# Linux and FreeBSD pgrep(1) completion. +# +[ $UNAME = Linux -o $UNAME = FreeBSD ] && +_pgrep() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + COMPREPLY=( $( compgen -W '$( command ps axo command | \ + sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \ + sed -e "s/.*\///" )' -- $cur ) ) + + return 0 +} +[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _pgrep pgrep +# Linux pidof(8) completion. +[ $UNAME = Linux ] && complete -F _pgrep pidof + +# GNU find(1) completion. This makes heavy use of ksh style extended +# globs and contains Linux specific code for completing the parameter +# to the -fstype option. +# +_find() +{ + local cur prev i exprfound onlyonce + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(max|min)depth) + COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- $cur ) ) + return 0 + ;; + -?(a|c)newer|-fls|-fprint?(0|f)|-?(i)?(l)name|-?(i)wholename) + _filedir + return 0 + ;; + -fstype) + # this is highly non-portable + [ -e /proc/filesystems ] && + COMPREPLY=( $( cut -d$'\t' -f 2 /proc/filesystems | \ + grep "^$cur" ) ) + return 0 + ;; + -gid) + _gids + return 0 + ;; + -group) + if [ -n "$bash205" ]; then + COMPREPLY=( $( compgen -g -- $cur 2>/dev/null) ) + fi + return 0 + ;; + -?(x)type) + COMPREPLY=( $( compgen -W 'b c d p f l s' -- $cur ) ) + return 0 + ;; + -uid) + _uids + return 0 + ;; + -user) + COMPREPLY=( $( compgen -u -- $cur ) ) + return 0 + ;; + -exec|-ok) + COMP_WORDS=(COMP_WORDS[0] $cur) + COMP_CWORD=1 + _command + return 0 + ;; + -[acm]min|-[acm]time|-?(i)?(l)name|-inum|-?(i)path|-?(i)regex| \ + -links|-perm|-size|-used|-printf) + # do nothing, just wait for a parameter to be given + return 0 + ;; + esac + + _expand || return 0 + + # set exprfound to 1 if there is already an expression present + for i in ${COMP_WORDS[@]}; do + [[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break + done + + # handle case where first parameter is not a dash option + if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then + _filedir -d + return 0 + fi + + # complete using basic options + COMPREPLY=( $( compgen -W '-daystart -depth -follow -help -maxdepth \ + -mindepth -mount -noleaf -version -xdev -amin -anewer \ + -atime -cmin -cnewer -ctime -empty -false -fstype \ + -gid -group -ilname -iname -inum -ipath -iregex \ + -wholename \ + -links -lname -mmin -mtime -name -newer -nouser \ + -nogroup -perm -regex -size -true -type -uid -used \ + -user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \ + -print -print0 -printf -prune -ls' -- $cur ) ) + + # this removes any options from the list of completions that have + # already been specified somewhere on the command line, as long as + # these options can only be used once (in a word, "options", in + # opposition to "tests" and "actions", as in the find(1) manpage). + onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \ + -noleaf -version -xdev ' + COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \ + (while read -d ' ' i; do + [ "$i" == "" ] || + [ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] && + continue + # flatten array with spaces on either side, + # otherwise we cannot grep on word boundaries of + # first and last word + COMPREPLY=" ${COMPREPLY[@]} " + # remove word from list of completions + COMPREPLY=( ${COMPREPLY/ ${i%% *} / } ) + done + echo "${COMPREPLY[@]}") + ) ) + + _filedir + + return 0 +} +complete -F _find $filenames find + +# Linux iwconfig(8) completion +# +[ $UNAME = Linux ] && have iwconfig && +_iwconfig() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + mode) + COMPREPLY=( $( compgen -W 'managed ad-hoc master \ + repeater secondary monitor' -- $cur ) ) + return 0 + ;; + essid) + COMPREPLY=( $( compgen -W 'on off any' -- $cur ) ) + if [ -n "${COMP_IWLIST_SCAN:-}" ]; then + COMPREPLY=( "${COMPREPLY[@]}" \ + $( iwlist ${COMP_WORDS[1]} scan | \ + awk -F '"' '/ESSID/ {print $2}' | \ + grep "^$cur" )) + fi + return 0 + ;; + nwid) + COMPREPLY=( $( compgen -W 'on off' -- $cur ) ) + return 0 + ;; + channel) + COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \ + awk '/^[[:space:]]*Channel/ {print $2}' | \ + grep "^$cur" ) ) + return 0 + ;; + + freq) + COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \ + awk '/^[[:space:]]*Channel/ {print $4"G"}' | \ + grep "^$cur" ) ) + return 0 + ;; + ap) + COMPREPLY=( $( compgen -W 'on off any' -- $cur ) ) + if [ -n "${COMP_IWLIST_SCAN:-}" ]; then + COMPREPLY=( "${COMPREPLY[@]}" \ + $( iwlist ${COMP_WORDS[1]} scan | \ + awk -F ': ' '/Address/ {print $2}' | \ + grep "^$cur" ) ) + fi + return 0 + ;; + rate) + COMPREPLY=( $( compgen -W 'auto fixed' -- $cur ) ) + COMPREPLY=( "${COMPREPLY[@]}" \ + $( iwlist ${COMP_WORDS[1]} rate | \ + awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | \ + grep "^$cur" ) ) + return 0 + ;; + rts) + COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) ) + return 0 + ;; + frag) + COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) ) + return 0 + ;; + key) + COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) ) + return 0 + ;; + enc) + COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) ) + return 0 + ;; + power) + COMPREPLY=( $( compgen -W 'period timeout off on' -- $cur ) ) + return 0 + ;; + txpower) + COMPREPLY=( $( compgen -W 'off on auto' -- $cur ) ) + return 0 + ;; + retry) + COMPREPLY=( $( compgen -W 'limit lifetime' -- $cur ) ) + return 0 + ;; + esac + + if [ $COMP_CWORD -eq 1 ]; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--help --version' -- $cur ) ) + else + _available_interfaces -w + fi + else + COMPREPLY=( $( compgen -W 'essid nwid mode freq channel sens mode \ + ap nick rate rts frag enc key power txpower commit' -- $cur ) ) + fi + +} && +complete -F _iwconfig iwconfig + +# Linux iwlist(8) completion +# +[ $UNAME = Linux ] && have iwlist && +_iwlist() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [ $COMP_CWORD -eq 1 ]; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--help --version' -- $cur ) ) + else + _available_interfaces -w + fi + else + COMPREPLY=( $( compgen -W 'scan scanning freq frequency \ + channel rate bit bitrate key enc encryption power \ + txpower retry ap accesspoint peers event' -- $cur ) ) + fi +} && +complete -F _iwlist iwlist + +# Linux iwspy(8) completion +# +[ $UNAME = Linux ] && have iwspy && +_iwspy() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD -eq 1 ]; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--help --version' -- $cur ) ) + else + _available_interfaces -w + fi + else + COMPREPLY=( $( compgen -W 'setthr getthr off' -- $cur ) ) + fi +} && +complete -F _iwspy iwspy + +# Linux iwpriv(8) completion +# +[ $UNAME = Linux ] && have iwpriv && +_iwpriv() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + roam) + COMPREPLY=( $( compgen -W 'on off' -- $cur ) ) + return 0 + ;; + port) + COMPREPLY=( $( compgen -W 'ad-hoc managed' -- $cur ) ) + return 0 + ;; + esac + + if [ $COMP_CWORD -eq 1 ]; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--help --version' -- $cur ) ) + else + _available_interfaces -w + fi + else + COMPREPLY=( $( compgen -W '--all roam port' -- $cur ) ) + fi +} && +complete -F _iwpriv iwpriv + +# RedHat & Debian GNU/Linux if{up,down} completion +# +[ $UNAME = Linux ] && { have ifup || have ifdown; } && +_ifupdown() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD -eq 1 ]; then + _configured_interfaces + COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + fi + + return 0 +} && +complete -F _ifupdown ifup ifdown +[ $UNAME = Linux ] && have ifstatus && complete -F _ifupdown ifstatus + +# Linux ipsec(8) completion (for FreeS/WAN) +# +[ $UNAME = Linux ] && have ipsec && +_ipsec() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look \ + manual pluto ranbits rsasigkey \ + setup showdefaults showhostkey spi \ + spigrp tncfg whack' -- $cur ) ) + return 0 + fi + + case ${COMP_WORDS[1]} in + auto) + COMPREPLY=( $( compgen -W '--asynchronous --up --add --delete \ + --replace --down --route --unroute \ + --ready --status --rereadsecrets' \ + -- $cur ) ) + ;; + manual) + COMPREPLY=( $( compgen -W '--up --down --route --unroute \ + --union' -- $cur ) ) + ;; + ranbits) + COMPREPLY=( $( compgen -W '--quick --continuous --bytes' \ + -- $cur ) ) + ;; + setup) + COMPREPLY=( $( compgen -W '--start --stop --restart' -- $cur ) ) + ;; + + *) + ;; + esac + + return 0 +} && +complete -F _ipsec ipsec + +# Postfix completion. +# +have postfix && { +# postfix(1) +# +_postfix() +{ + local cur prev + + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [[ $cur == '-' ]]; then + COMPREPLY=(-c -D -v) + return 0 + fi + if [[ $prev == '-c' ]]; then + _filedir -d + return 0 + fi + if [[ $prev == '-D' ]]; then + COMPREPLY=( $( compgen -W 'start' -- "`get_cword`" ) ) + return 0 + fi + COMPREPLY=( $( compgen -W 'start stop reload abort flush check' -- \ + "`get_cword`" ) ) +} +complete -F _postfix postfix + +# postalias(1) and postmap(1) +# +_postmap() +{ + local cur prev len idx + + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [[ $cur == '-' ]]; then + COMPREPLY=(-N -f -i -n -o -p -r -v -w -c -d -q) + return 0 + fi + if [[ $prev == '-c' ]]; then + _filedir -d + return 0 + fi + if [[ $prev == -[dq] ]]; then + return 0 + fi + + if [[ "$cur" == *:* ]]; then + COMPREPLY=( $( compgen -f -- ${cur#*:} ) ) + else + len=${#cur} + idx=0 + for pval in $( /usr/sbin/postconf -m ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]="$pval:" + idx=$(($idx+1)) + fi + done + if [[ $idx -eq 0 ]]; then + COMPREPLY=( $( compgen -f -- "$cur" ) ) + fi + fi + return 0 +} +complete -F _postmap postmap postalias + +# postcat(1) +# +_postcat() +{ + local cur prev pval len idx qfile + + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [[ $cur == '-' ]]; then + COMPREPLY=(-c -q -v) + return 0 + fi + if [[ $prev == '-c' ]]; then + _filedir -d + return 0 + fi + + qfile=0 + for idx in "${COMP_WORDS[@]}"; do + [[ "$idx" = -q ]] && qfile=1 && break + done + if [[ $qfile == 1 ]]; then + len=${#cur} + idx=0 + for pval in $( mailq | \ + sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]=$pval + idx=$(($idx+1)) + fi + done + return 0 + else + _filedir + return 0 + fi +} +complete -F _postcat postcat + +# postconf(1) +# +_postconf() +{ + local cur prev pval len idx eqext + + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + if [[ $cur == '-' ]]; then + COMPREPLY=(-c -d -e -h -m -l -n -v) + return 0 + fi + if [[ $prev == '-c' ]]; then + _filedir -d + return 0 + fi + if [[ $prev == '-e' ]]; then + cur=${cur#[\"\']} + eqext='=' + fi + len=${#cur} + idx=0 + for pval in $( /usr/sbin/postconf | cut -d ' ' -f 1 ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]="$pval$eqext" + idx=$(($idx+1)) + fi + done + return 0 +} +complete -F _postconf postconf + +# postsuper(1) +# +_postsuper() +{ + local cur prev pval len idx + + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [[ $cur == '-' ]]; then + COMPREPLY=(-c -d -h -H -p -r -s -v) + return 0 + fi + case $prev in + -[dr]) + len=${#cur} + idx=0 + for pval in $( echo ALL; mailq | \ + sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]=$pval + idx=$(($idx+1)) + fi + done + return 0 + ;; + -h) + len=${#cur} + idx=0 + for pval in $( echo ALL; mailq | \ + sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]=$pval + idx=$(($idx+1)) + fi + done + return 0 + ;; + -H) + len=${#cur} + idx=0 + for pval in $( echo ALL; mailq | \ + sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]=$pval + idx=$(($idx+1)) + fi + done + return 0 + ;; + esac + COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- $cur ) ) + return 0 +} +complete -F _postsuper postsuper +} + +# cvs(1) completion +# +have cvs && { +set_prefix() +{ + [ -z ${prefix:-} ] || prefix=${cur%/*}/ + [ -r ${prefix:-}CVS/Entries ] || prefix="" +} + +get_entries() +{ + local IFS=$'\n' + [ -r ${prefix:-}CVS/Entries ] && \ + entries=$(cut -d/ -f2 -s ${prefix:-}CVS/Entries) +} + +get_modules() +{ + if [ -n "$prefix" ]; then + COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) ) + else + COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) ) + fi +} + +_cvs() +{ + local cur count mode i cvsroot cvsroots pwd + local -a flags miss files entries changed newremoved + + COMPREPLY=() + cur=`_get_cword` + + count=0 + for i in "${COMP_WORDS[@]}"; do + [ $count -eq $COMP_CWORD ] && break + # Last parameter was the CVSROOT, now go back to mode selection + if [ "${COMP_WORDS[((count))]}" == "$cvsroot" -a "$mode" == "cvsroot" ]; then + mode="" + fi + if [ -z "$mode" ]; then + case $i in + -d) + mode=cvsroot + cvsroot=${COMP_WORDS[((count+1))]} + ;; + @(ad?(d)|new)) + mode=add + ;; + @(adm?(in)|rcs)) + mode=admin + ;; + ann?(notate)) + mode=annotate + ;; + @(checkout|co|get)) + mode=checkout + ;; + @(com?(mit)|ci)) + mode=commit + ;; + di?(f?(f))) + mode=diff + ;; + ex?(p?(ort))) + mode=export + ;; + ?(un)edit) + mode=$i + ;; + hi?(s?(tory))) + mode=history + ;; + im?(p?(ort))) + mode=import + ;; + re?(l?(ease))) + mode=release + ;; + ?(r)log) + mode=log + ;; + @(rdiff|patch)) + mode=rdiff + ;; + @(remove|rm|delete)) + mode=remove + ;; + @(rtag|rfreeze)) + mode=rtag + ;; + st?(at?(us))) + mode=status + ;; + @(tag|freeze)) + mode=tag + ;; + up?(d?(ate))) + mode=update + ;; + *) + ;; + esac + elif [[ "$i" = -* ]]; then + flags=( "${flags[@]}" $i ) + fi + count=$((++count)) + done + + case "$mode" in + add) + if [[ "$cur" != -* ]]; then + set_prefix + if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then + get_entries + [ -z "$cur" ] && \ + files=$( command ls -Ad !(CVS) ) || \ + files=$( command ls -d ${cur}* 2>/dev/null ) + for i in "${entries[@]}"; do + files=( ${files[@]/#$i//} ) + done + COMPREPLY=( $( compgen -W '${files[@]}' -- \ + $cur ) ) + fi + else + COMPREPLY=( $( compgen -W '-k -m' -- $cur ) ) + fi + ;; + admin) + if [[ "$cur" = -* ]]; then + COMPREPLY=( $( compgen -W '-i -a -A -e -b -c -k -l -u \ + -L -U -m -M -n -N -o -q -I \ + -s -t -t- -T -V -x -z' -- \ + $cur ) ) + fi + ;; + annotate) + if [[ "$cur" = -* ]]; then + COMPREPLY=( $( compgen -W '-D -F -f -l -R -r' -- $cur ) ) + else + get_entries + COMPREPLY=( $( compgen -W '${entries[@]}' -- $cur ) ) + fi + ;; + checkout) + if [[ "$cur" != -* ]]; then + [ -z "$cvsroot" ] && cvsroot=$CVSROOT + COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \ + awk '{print $1}' ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) ) + else + COMPREPLY=( $( compgen -W '-A -N -P -R -c -f -l -n -p \ + -s -r -D -d -k -j' -- $cur ) ) + fi + ;; + commit) + set_prefix + + if [[ "$cur" != -* ]] && [ -r ${prefix:-}CVS/Entries ]; then + # if $COMP_CVS_REMOTE is not null, 'cvs commit' will + # complete on remotely checked-out files (requires + # passwordless access to the remote repository + if [ -n "${COMP_CVS_REMOTE:-}" ]; then + # this is the least computationally intensive + # way found so far, but other changes + # (something other than changed/removed/new) + # may be missing + changed=( $( cvs -q diff --brief 2>&1 | \ + sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) ) + newremoved=( $( cvs -q diff --brief 2>&1 | \ + sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) ) + COMPREPLY=( $( compgen -W '${changed[@]:-} \ + ${newremoved[@]:-}' -- $cur ) ) + else + _filedir + fi + else + COMPREPLY=( $( compgen -W '-n -R -l -f -F -m -r' -- \ + $cur ) ) + fi + ;; + cvsroot) + if [ -r ~/.cvspass ]; then + # Ugly escaping because of bash treating ':' specially + cvsroots=$( sed 's/^[^ ]* //; s/:/\\:/g' ~/.cvspass ) + COMPREPLY=( $( compgen -W '$cvsroots' -- $cur ) ) + fi + ;; + export) + if [[ "$cur" != -* ]]; then + [ -z "$cvsroot" ] && cvsroot=$CVSROOT + COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) ) + else + COMPREPLY=( $( compgen -W '-N -f -l -R -n \ + -r -D -d -k' -- $cur ) ) + fi + ;; + diff) + if [[ "$cur" == -* ]]; then + _longopt diff + else + get_entries + COMPREPLY=( $( compgen -W '${entries[@]:-}' -- $cur ) ) + fi + ;; + remove) + if [[ "$cur" != -* ]]; then + set_prefix + if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then + get_entries + # find out what files are missing + for i in "${entries[@]}"; do + [ ! -r "$i" ] && miss=( "${miss[@]}" $i ) + done + COMPREPLY=( $(compgen -W '${miss[@]:-}' -- $cur) ) + fi + else + COMPREPLY=( $( compgen -W '-f -l -R' -- $cur ) ) + fi + ;; + import) + if [[ "$cur" != -* ]]; then + # starts with same algorithm as checkout + [ -z "$cvsroot" ] && cvsroot=$CVSROOT + prefix=${cur%/*} + if [ -r ${cvsroot}/${prefix} ]; then + get_modules + COMPREPLY=( ${COMPREPLY[@]#$cvsroot} ) + COMPREPLY=( ${COMPREPLY[@]#\/} ) + fi + pwd=$( pwd ) + pwd=${pwd##*/} + COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- \ + $cur ) ) + else + COMPREPLY=( $( compgen -W '-d -k -I -b -m -W' -- $cur )) + fi + ;; + update) + if [[ "$cur" = -* ]]; then + COMPREPLY=( $( compgen -W '-A -P -C -d -f -l -R -p \ + -k -r -D -j -I -W' -- \ + $cur ) ) + fi + ;; + "") + COMPREPLY=( $( compgen -W 'add admin annotate checkout ci co \ + commit diff delete edit export \ + freeze get history import log new \ + patch rcs rdiff release remove \ + rfreeze rlog rm rtag stat status \ + tag unedit up update -H -Q -q -b \ + -d -e -f -l -n -t -r -v -w -x -z \ + --help --version' -- $cur ) ) + ;; + *) + ;; + esac + + return 0 +} +complete -F _cvs $default cvs +} + +have rpm && { +# helper functions for rpm completion +# +_rpm_installed_packages() +{ + local ver nodig nosig + + if [ -r /var/log/rpmpkgs -a \ + /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then + # using RHL 7.2 or later - this is quicker than querying the DB + COMPREPLY=( $( sed -ne \ + 's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+.*\.rpm$|\1|p' \ + /var/log/rpmpkgs ) ) + else + nodig="" + nosig="" + ver=$(rpm --version) + ver=${ver##* } + + if [[ "$ver" > "4.0.4" ]]; then + nodig="--nodigest" + fi + if [[ "$ver" > "4.0.99" ]]; then + nosig="--nosignature" + fi + + COMPREPLY=( $( rpm -qa $nodig $nosig | sed -ne \ + 's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+$|\1|p' ) ) + fi +} + +_rpm_groups() +{ + local IFS=$'\t' + # remove trailing backslash, or grep will complain + cur=${cur%"\\"} + COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \ + grep "^$cur" ) ) + # backslash escape spaces and translate newlines to tabs + COMPREPLY=( $( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ) ) +} + +# rpm(8) completion +# +_rpm() +{ + local cur prev ver nodig nosig + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + nodig="" + nosig="" + ver=$(rpm --version); ver=${ver##* } + + if [[ "$ver" > "4.0.4" ]]; then + nodig="--nodigest" + fi + if [[ "$ver" > "4.0.99" ]]; then + nosig="--nosignature" + fi + + if [ $COMP_CWORD -eq 1 ]; then + # first parameter on line + case "$cur" in + -b*) + COMPREPLY=( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs'\ + -- $cur ) ) + ;; + -t*) + COMPREPLY=( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts'\ + -- $cur ) ) + ;; + --*) + COMPREPLY=( $( compgen -W '--help --version --initdb \ + --checksig --recompile --rebuild --resign --addsign \ + --rebuilddb --showrc --setperms --setugids --tarbuild \ + --eval --install --upgrade --query --freshen --erase \ + --verify --querytags --rmsource --rmspec --clean \ + --import' -- $cur ) ) + ;; + *) + COMPREPLY=( $( compgen -W '-b -e -F -i -q -t -U -V' \ + -- $cur ) ) + ;; + esac + + return 0 + fi + + case "$prev" in + --@(@(db|exclude)path|prefix|relocate|root)) + _filedir -d + return 0 + ;; + --eval) + # get a list of macros + COMPREPLY=( $( sed -ne 's|^\(%'${cur#\%}'[^ '$'\t'']*\).*$|\1|p' \ + /usr/lib/rpm/macros ) ) + return 0 + ;; + --pipe) + COMPREPLY=( $( compgen -c -- $cur ) ) + return 0 + ;; + --rcfile) + _filedir + return 0 + ;; + --specfile) + # complete on .spec files + _filedir spec + return 0 + ;; + --whatprovides) + if [[ "$cur" == */* ]]; then + _filedir + else + # complete on capabilities + COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \ + '%{providename}\n' | grep "^$cur" ) ) + fi + return 0 + ;; + --whatrequires) + # complete on capabilities + COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \ + '%{requirename}\n' | grep "^$cur" ) ) + return 0 + ;; + esac + + case "${COMP_WORDS[1]}" in + -@([iFU]*|-install|-freshen|-upgrade)) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--percent --force --test \ + --replacepkgs --replacefiles --root --excludedocs \ + --includedocs --noscripts --rcfile --ignorearch \ + --dbpath --prefix --ignoreos --nodeps --allfiles \ + --ftpproxy --ftpport --justdb --httpproxy --httpport \ + --noorder --relocate --badreloc --notriggers \ + --excludepath --ignoresize --oldpackage --define \ + --eval --pipe --queryformat --repackage --nosuggests \ + --nodigest --nosignature' -- $cur ) ) + else + _filedir 'rpm' + fi + ;; + -@(e|-erase)) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--allmatches --noscripts \ + --notriggers --nodeps --test --repackage' -- $cur ) ) + else + _rpm_installed_packages + fi + ;; + -@(q*|-query)) + # check whether we're doing file completion + if [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--scripts --root \ + --rcfile --requires --ftpport --ftpproxy \ + --httpproxy --httpport --provides --triggers \ + --dump --changelog --dbpath \ + --last --filesbypkg \ + --info --list --state \ + --docfiles --configfiles --queryformat \ + --conflicts --obsoletes \ + --nodigest --nosignature \ + --triggerscripts' -- $cur ) ) + else + _filedir + fi + elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then + _rpm_groups + elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then + # uninstalled package completion + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--scripts --root \ + --rcfile --whatprovides --whatrequires \ + --requires --triggeredby --ftpport --ftpproxy \ + --httpproxy --httpport --provides --triggers \ + --dump --changelog --dbpath --filesbypkg \ + --define --eval --pipe --showrc --info --list \ + --state --docfiles --configfiles --queryformat\ + --conflicts --obsoletes --nodigest \ + --nosignature' -- $cur ) ) + else + _filedir 'rpm' + fi + else + # installed package completion + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--scripts --root \ + --rcfile --whatprovides --whatrequires \ + --requires --triggeredby --ftpport --ftpproxy \ + --httpproxy --httpport --provides --triggers \ + --dump --changelog --dbpath --specfile \ + --querybynumber --last --filesbypkg --define \ + --eval --pipe --showrc --info --list --state \ + --docfiles --configfiles --queryformat \ + --conflicts --obsoletes --pkgid --hdrid \ + --fileid --tid --nodigest --nosignature \ + --triggerscripts' -- $cur ) ) + elif [ "${COMP_LINE#* -*([^ -])a}" == "$COMP_LINE" ]; then + _rpm_installed_packages + fi + fi + ;; + -@(K*|-checksig)) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--nopgp --nogpg --nomd5 \ + --nodigest --nosignature' -- $cur ) ) + else + _filedir 'rpm' + fi + ;; + -@([Vy]*|-verify)) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--root --rcfile --dbpath \ + --nodeps --nogroup --nolinkto --nomode --nomtime \ + --nordev --nouser --nofiles --noscripts --nomd5 \ + --querytags --specfile --whatrequires --whatprovides \ + --nodigest --nosignature' -- $cur ) ) + # check whether we're doing file completion + elif [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then + _filedir + elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then + _rpm_groups + elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then + _filedir 'rpm' + else + _rpm_installed_packages + fi + ;; + -[bt]*) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--short-circuit --timecheck \ + --clean --rmsource --rmspec --test --sign --buildroot \ + --target -- buildarch --buildos --nobuild --nodeps \ + --nodirtokens' -- $cur ) ) + elif [[ ${COMP_WORDS[1]} == -b* ]]; then + _filedir 'spec' + else + _filedir '@(tgz|tar.@(gz|bz2))' + fi + ;; + --re@(build|compile)) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--nodeps --rmsource \ + --rmspec --sign --nodirtokens --target' -- $cur ) ) + else + _filedir '?(no)src.rpm' + fi + ;; + --tarbuild) + _filedir '@(tgz|tar.@(gz|bz2))' + ;; + --@(re|add)sign) + _filedir 'rpm' + ;; + --set@(perms|gids)) + _rpm_installed_packages + ;; + --@(clean|rms@(ource|pec))) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--clean --rmsource \ + --rmspec' -- $cur ) ) + else + _filedir 'spec' + fi + ;; + --@(import|dbpath|root)) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--import --dbpath --root' \ + -- $cur ) ) + else + _filedir + fi + ;; + esac + + return 0 +} +complete -F _rpm $filenames rpm rpmbuild +} + +# Debian apt-get(8) completion. +# +have apt-get && +_apt_get() +{ + local cur prev special i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == @(install|remove|purge|source|build-dep) ]]; then + special=${COMP_WORDS[i]} + fi + done + + if [ -n "$special" ]; then + case $special in + remove|purge) + if [ -f /etc/debian_version ]; then + # Debian system + COMPREPLY=( $( _comp_dpkg_installed_packages \ + $cur ) ) + else + # assume RPM based + _rpm_installed_packages + fi + return 0 + ;; + *) + COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) ) + return 0 + ;; + + esac + fi + + case "$prev" in + -@(c|-config-file)) + _filedir + return 0 + ;; + + -@(t|-target-release|-default-release)) + COMPREPLY=( $( apt-cache policy | \ + grep "release.o=Debian,a=$cur" | \ + sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) ) + return 0 + ;; + + esac + + if [[ "$cur" == -* ]]; then + + COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y \ + -u -t -b -c -o --download-only --fix-broken \ + --help --version --ignore-missing \ + --fix-missing --no-download --quiet --simulate \ + --just-print --dry-run --recon --no-act --yes \ + --assume-yes --show-upgraded --only-source \ + --compile --build --ignore-hold \ + --target-release --no-upgrade --force-yes \ + --print-uris --purge --reinstall \ + --list-cleanup --default-release \ + --trivial-only --no-remove --diff-only \ + --tar-only --config-file --option --auto-remove' -- $cur ) ) + else + + COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \ + dist-upgrade install remove purge source \ + build-dep check clean autoclean autoremove' \ + -- $cur ) ) + + fi + + + return 0 +} && +complete -F _apt_get $filenames apt-get + +# Debian apt-cache(8) completion. +# +have apt-cache && +_apt_cache() +{ + local cur prev special i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + + if [ "$cur" != show ]; then + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|policy|rdepends|madison|show?(pkg|src|)) ]]; then + special=${COMP_WORDS[i]} + fi + done + fi + + + if [ -n "$special" ]; then + case $special in + add) + _filedir + return 0 + ;; + + *) + COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) ) + return 0 + ;; + + esac + fi + + + case "$prev" in + -@(c|p|s|-config-file|-@(pkg|src)-cache)) + _filedir + return 0 + ;; + search) + if [[ "$cur" != -* ]]; then + return 0 + fi + ;; + esac + + if [[ "$cur" == -* ]]; then + + COMPREPLY=( $( compgen -W '-h -v -p -s -q -i -f -a -g -c \ + -o --help --version --pkg-cache --src-cache \ + --quiet --important --full --all-versions \ + --no-all-versions --generate --no-generate \ + --names-only --all-names --recurse \ + --config-file --option' -- $cur ) ) + else + + COMPREPLY=( $( compgen -W 'add gencaches show showpkg showsrc \ + stats dump dumpavail unmet search search \ + depends rdepends pkgnames dotty xvcg \ + policy madison' -- $cur ) ) + + fi + + + return 0 +} && +complete -F _apt_cache $filenames apt-cache + + +# Debian aptitude(1) completion +# +have aptitude && { +have grep-status && { +_comp_dpkg_hold_packages() +{ + grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package +} +} || { +_comp_dpkg_hold_packages() +{ + grep -B 2 'hold' /var/lib/dpkg/status | grep "Package: $1" \ + | cut -d\ -f2 +} +} + +_aptitude() +{ + local cur dashoptions prev special i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + + dashoptions='-S -u -i -h --help --version -s --simulate -d \ + --download-only -P --prompt -y --assume-yes -F \ + --display-format -O --sort -w --width -f -r -g \ + --with-recommends --with-suggests -R -G \ + --without-recommends --without-suggests -t \ + --target-release -V --show-versions -D --show-deps\ + -Z -v --verbose --purge-unused' + + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == @(install|reinstall|hold|unhold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|forbid-version|purge|remove|changelog|why|why-not|keep|keep-all) ]]; then + special=${COMP_WORDS[i]} + fi + #exclude some mutually exclusive options + [[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i} + [[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u} + done + + if [[ -n "$special" ]]; then + case $special in + @(install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|changelog|why|why-not)) + COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) ) + return 0 + ;; + @(purge|remove|reinstall|forbid-version)) + COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) ) + return 0 + ;; + unhold) + COMPREPLY=( $( _comp_dpkg_hold_packages $cur ) ) + return 0 + ;; + + esac + fi + + case $prev in + # don't complete anything if these options are found + @(autoclean|clean|forget-new|search|upgrade|safe-upgrade|update|keep-all)) + return 0 + ;; + + -S) + _filedir + return 0 + ;; + + -@(t|-target-release|-default-release)) + COMPREPLY=( $( apt-cache policy | \ + grep "release.o=Debian,a=$cur" | \ + sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) ) + return 0 + ;; + + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) ) + else + COMPREPLY=( $( compgen -W 'update upgrade safe-upgrade forget-new clean \ + autoclean install reinstall remove \ + hold unhold purge markauto unmarkauto why why-not \ + dist-upgrade full-upgrade download search show \ + forbid-version changelog keep-all' -- $cur ) ) + fi + + + return 0 +} +complete -F _aptitude $default aptitude +} + +# Debian apt-build(1) completion. +# +have apt-build && +_apt_build() +{ + local cur prev special i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then + special=${COMP_WORDS[i]} + fi + done + + if [ -n "$special" ]; then + case $special in + @(install|source|info)) + COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) ) + return 0 + ;; + remove) + COMPREPLY=( $( _comp_dpkg_installed_packages \ + $cur ) ) + return 0 + ;; + *) + return 0 + ;; + esac + fi + + case "$prev" in + + --@(patch|build-dir|repository-dir)) + _filedir + return 0 + ;; + + -@(h|-help)) + return 0 + ;; + + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir \ + --repository-dir --build-only \ + --build-command --reinstall --rebuild \ + --remove-builddep --no-wrapper --purge \ + --patch --patch-strip -p --yes -y \ + --version -v --no-source' -- $cur ) ) + + else + COMPREPLY=( $( compgen -W 'update upgrade install remove \ + source dist-upgrade world clean info \ + clean-build update-repository ' -- $cur ) ) + fi + + + return 0 +} && +complete -F _apt_build $filenames apt-build + +# chsh(1) completion +# +_chsh() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [ "$prev" = "-s" ]; then + if [ -f /etc/debian_version ]; then + COMPREPLY=( $( /dev/null ) ) + fi + if [ ${#khd[@]} -gt 0 ]; then + # Needs to look for files called + # .../.ssh2/key_22_.pub + # dont fork any processes, because in a cluster environment, + # there can be hundreds of hostkeys + for i in "${khd[@]}" ; do + if [[ "$i" == *key_22_$curd*.pub ]] && [ -r "$i" ] ; then + host=${i/#*key_22_/} + host=${host/%.pub/} + COMPREPLY=( "${COMPREPLY[@]}" $host ) + fi + done + fi + + # append any available aliases from config files + if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then + local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^*?]*\)$/\2/p' "${config[@]}" ) + hosts=$( compgen -W "$host_aliases" -- $ocur ) + COMPREPLY=( "${COMPREPLY[@]}" $hosts ) + fi + + # Now add results of normal hostname completion + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -- $ocur ) ) + + # apply suffix + for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do + COMPREPLY[i]=$user${COMPREPLY[i]}$suffix + done + else + # Just do normal hostname completion + COMPREPLY=( $( compgen -A hostname -S "$suffix" -- $cur ) ) + fi + + return 0 +} +complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \ + ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr + +# ssh(1) completion +# +have ssh && { +_ssh() +{ + local cur prev + local -a config + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -*c) + COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \ + arcfour cast128-cbc' -- $cur ) ) + ;; + -*i) + _filedir + ;; + -*l) + COMPREPLY=( $( compgen -u -- $cur ) ) + ;; + *) + _known_hosts -a + + [ $COMP_CWORD -eq 1 ] || \ + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) ) + esac + + return 0 +} +shopt -u hostcomplete && complete -F _ssh ssh slogin sftp xhost autossh + +# scp(1) completion +# +_scp() +{ + local cur userhost path + + COMPREPLY=() + cur=`_get_cword` + + _expand || return 0 + + if [[ "$cur" == *:* ]]; then + local IFS=$'\t\n' + # remove backslash escape from : + cur=${cur/\\:/:} + userhost=${cur%%?(\\):*} + path=${cur#*:} + # unescape spaces + path=${path//\\\\\\\\ / } + if [ -z "$path" ]; then + # default to home dir of specified user on remote host + path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null) + fi + # escape spaces; remove executables, aliases, pipes and sockets; + # add space at end of file names + COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \ + command ls -aF1d "$path*" 2>/dev/null | \ + sed -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\\\\\\\\\&/g" \ + -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) ) + return 0 + fi + + [[ "$cur" == */* ]] || _known_hosts -c -a + local IFS=$'\t\n' + COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \ + 2>/dev/null | sed \ + -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \ + -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) ) + return 0 +} +complete -F _scp $nospace scp +} + +# rsync(1) completion +# +have rsync && +_rsync() +{ + local cur prev shell i userhost path + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + _expand || return 0 + + case "$prev" in + --@(config|password-file|include-from|exclude-from)) + _filedir + return 0 + ;; + -@(T|-temp-dir|-compare-dest)) + _filedir -d + return 0 + ;; + -@(e|-rsh)) + COMPREPLY=( $( compgen -W 'rsh ssh' -- $cur ) ) + return 0 + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W '-v -q -c -a -r -R -b -u -l -L -H \ + -p -o -g -D -t -S -n -W -x -B -e -C -I -T -P \ + -z -h -4 -6 --verbose --quiet --checksum \ + --archive --recursive --relative --backup \ + --backup-dir --suffix= --update --links \ + --copy-links --copy-unsafe-links --safe-links \ + --hard-links --perms --owner --group --devices\ + --times --sparse --dry-run --whole-file \ + --no-whole-file --one-file-system \ + --block-size= --rsh= --rsync-path= \ + --cvs-exclude --existing --ignore-existing \ + --delete --delete-excluded --delete-after \ + --ignore-errors --max-delete= --partial \ + --force --numeric-ids --timeout= \ + --ignore-times --size-only --modify-window= \ + --temp-dir= --compare-dest= --compress \ + --exclude= --exclude-from= --include= \ + --include-from= --version --daemon --no-detach\ + --address= --config= --port= --blocking-io \ + --no-blocking-io --stats --progress \ + --log-format= --password-file= --bwlimit= \ + --write-batch= --read-batch= --help' -- $cur )) + ;; + *:*) + # find which remote shell is used + shell=rsh + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then + shell=${COMP_WORDS[i+1]} + break + fi + done + if [[ "$shell" == ssh ]]; then + # remove backslash escape from : + cur=${cur/\\:/:} + userhost=${cur%%?(\\):*} + path=${cur#*:} + # unescape spaces + path=${path//\\\\\\\\ / } + if [ -z "$path" ]; then + # default to home dir of specified + # user on remote host + path=$(ssh -o 'Batchmode yes' \ + $userhost pwd 2>/dev/null) + fi + # escape spaces; remove executables, aliases, pipes + # and sockets; add space at end of file names + COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \ + command ls -aF1d "$path*" 2>/dev/null | \ + sed -e 's/ /\\\\\\\ /g' -e 's/[*@|=]$//g' \ + -e 's/[^\/]$/& /g' ) ) + fi + ;; + *) + _known_hosts -c -a + _filedir + ;; + esac + + return 0 +} && +complete -F _rsync $nospace $filenames rsync + +# Linux route(8) completion +# +[ $UNAME = Linux ] && +_route() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [ "$prev" = dev ]; then + COMPREPLY=( $( ifconfig -a | sed -ne 's|^\('$cur'[^ ]*\).*$|\1|p' )) + return 0 + fi + + COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \ + window irtt reject mod dyn reinstate dev \ + default gw' -- $cur ) ) + + COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \ + (while read -d ' ' i; do + [ "$i" == "" ] && continue + # flatten array with spaces on either side, + # otherwise we cannot grep on word + # boundaries of first and last word + COMPREPLY=" ${COMPREPLY[@]} " + # remove word from list of completions + COMPREPLY=( ${COMPREPLY/ $i / } ) + done + echo "${COMPREPLY[@]}") + ) ) + return 0 +} +[ $UNAME = Linux ] && complete -F _route route + +# GNU make(1) completion +# +have make || have gmake || have gnumake || have pmake && +_make() +{ + local file makef makef_dir="." makef_inc cur prev i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + # --name value style option + case $prev in + -@(f|o|W)) + _filedir + return 0 + ;; + -@(I|C)) + _filedir -d + return 0 + ;; + esac + + # --name=value style option + if [[ "$cur" == *=* ]]; then + prev=${cur/=*/} + cur=${cur/*=/} + case "$prev" in + --@(file|makefile)) + _filedir + return 0 + ;; + --@(directory|include-dir)) + _filedir -d + return 0 + ;; + esac + fi + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-b -m -B -C -d -e -f -h -i -I\ + -j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \ + --always-make --directory= --debug \ + --environment-overrides --file= --makefile= --help \ + --ignore-errors --include-dir= --jobs --load-average \ + --max-load --keep-going --just-print --dry-run \ + --recon --old-file= --assume-old= --print-data-base \ + --question --no-builtin-rules --no-builtin-variables \ + --silent --quiet --no-keep-goind --stop --touch \ + --version --print-directory --no-print-directory \ + --what-if= --new-file= --assume-new= \ + --warn-undefined-variables' -- $cur ) ) + else + # before we check for makefiles, see if a path was specified + # with -C + for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do + if [[ ${COMP_WORDS[i]} == -C ]]; then + # eval for tilde expansion + eval makef_dir=${COMP_WORDS[i+1]} + break + fi + done + + # make reads `GNUmakefile', then `makefile', then `Makefile' + if [ -f ${makef_dir}/GNUmakefile ]; then + makef=${makef_dir}/GNUmakefile + elif [ -f ${makef_dir}/makefile ]; then + makef=${makef_dir}/makefile + elif [ -f ${makef_dir}/Makefile ]; then + makef=${makef_dir}/Makefile + else + makef=${makef_dir}/*.mk # local convention + fi + + # before we scan for targets, see if a Makefile name was + # specified with -f + for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do + if [[ ${COMP_WORDS[i]} == -f ]]; then + # eval for tilde expansion + eval makef=${COMP_WORDS[i+1]} + break + fi + done + + [ ! -f $makef ] && return 0 + + # deal with included Makefiles + makef_inc=$( grep -E '^-?include' $makef | sed -e "s,^.* ,"$makef_dir"/," ) + + for file in $makef_inc; do + [ -f $file ] && makef="$makef $file" + done + + COMPREPLY=( $( awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \ + {split($1,A,/ /);for(i in A)print A[i]}' \ + $makef 2>/dev/null | command grep "^$cur" )) + fi +} && +complete -f -F _make $filenames make gmake gnumake pmake + +# GNU tar(1) completion +# +_tar() +{ + local cur ext regex tar untar + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W 'c t x u r d A' -- $cur ) ) + return 0 + fi + + case "${COMP_WORDS[1]}" in + ?(-)[cr]*f) + _filedir + return 0 + ;; + +([^IZzjy])f) + ext='t@(ar?(.@(Z|gz|bz?(2)))|gz|bz?(2))' + regex='t\(ar\(\.\(Z\|gz\|bz2\?\)\)\?\|gz\|bz2\?\)' + ;; + *[Zz]*f) + ext='t?(ar.)@(gz|Z)' + regex='t\(ar\.\)\?\(gz\|Z\)' + ;; + *[Ijy]*f) + ext='t?(ar.)bz?(2)' + regex='t\(ar\.\)\?bz2\?' + ;; + *) + _filedir + return 0 + ;; + + esac + + if [[ "$COMP_LINE" == *$ext' ' ]]; then + # complete on files in tar file + # + # get name of tar file from command line + tar=$( echo "$COMP_LINE" | \ + sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' ) + # devise how to untar and list it + untar=t${COMP_WORDS[1]//[^Izjyf]/} + + COMPREPLY=( $( compgen -W "$( echo $( tar $untar $tar \ + 2>/dev/null ) )" -- "$cur" ) ) + return 0 + fi + + # file completion on relevant files + _filedir "$ext" + + return 0 +} +[ -n "${COMP_TAR_INTERNAL_PATHS:-}" ] && complete -F _tar $dirnames tar || + complete -F _tar $filenames tar + +# jar(1) completion +# +have jar && +_jar() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD = 1 ]; then + COMPREPLY=( $( compgen -W 'c t x u' -- $cur ) ) + return 0 + fi + + case "${COMP_WORDS[1]}" in + *c*f) + _filedir + ;; + *f) + _filedir '?(e|j|w)ar' + ;; + *) + _filedir + ;; + esac +} && +complete -F _jar $filenames jar + +# Linux iptables(8) completion +# +have iptables && +_iptables() +{ + local cur prev table chain + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + chain='s/^Chain \([^ ]\+\).*$/\1/p' + + if [[ $COMP_LINE == *-t\ *filter* ]]; then + table="-t filter" + elif [[ $COMP_LINE == *-t\ *nat* ]]; then + table="-t nat" + elif [[ $COMP_LINE == *-t\ *mangle* ]]; then + table="-t mangle" + fi + + case "$prev" in + -*[AIDRPFXLZ]) + COMPREPLY=( $( compgen -W '`iptables $table -nL | \ + sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' -- $cur ) ) + ;; + -*t) + COMPREPLY=( $( compgen -W 'nat filter mangle' -- $cur ) ) + ;; + -j) + if [ "$table" = "-t filter" -o "$table" = "" ]; then + COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ + `iptables $table -nL | sed -ne "$chain" \ + -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ + $cur ) ) + elif [ "$table" = "-t nat" ]; then + COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ + MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \ + sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \ + -- $cur ) ) + elif [ "$table" = "-t mangle" ]; then + COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ + MARK TOS `iptables $table -nL | sed -ne "$chain" \ + -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ + $cur ) ) + fi + ;; + *) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-i -o -s -d -p -f -m --append \ + --delete --insert --replace --list --flush --zero --new \ + --delete-chain --policy --rename-chain --proto --source \ + --destination --in-interface --jump --match --numeric \ + --out-interface --table --verbose --line-numbers --exact \ + --fragment --modprobe= --set-counters --version' -- "$cur") ) + fi + ;; + esac + +} && +complete -F _iptables iptables + +# tcpdump(8) completion +# +have tcpdump && +_tcpdump() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(r|w|F)) + _filedir + return 0 + ;; + -i) + _available_interfaces -a + return 0 + ;; + esac + + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-a -d -e -f -l -n -N -O -p \ + -q -R -S -t -u -v -x -C -F -i -m -r -s -T -w \ + -E' -- $cur ) ) + fi + +} && +complete -F _tcpdump tcpdump + +# autorpm(8) completion +# +have autorpm && +_autorpm() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + COMPREPLY=( $( compgen -W '--notty --debug --help --version \ + auto add fullinfo info help install list \ + remove set' -- $cur ) ) + +} && +complete -F _autorpm autorpm + +# This meta-cd function observes the CDPATH variable, so that cd additionally +# completes on directories under those specified in CDPATH. +# +_cd() +{ + local IFS=$'\t\n' cur=`_get_cword` i j k + + # try to allow variable completion + if [[ "$cur" == ?(\\)\$* ]]; then + COMPREPLY=( $( compgen -v -P '$' -- "${cur#?(\\)$}" ) ) + return 0 + fi + + # Use standard dir completion if no CDPATH or parameter starts with /, + # ./ or ../ + if [ -z "${CDPATH:-}" ] || [[ "$cur" == ?(.)?(.)/* ]]; then + _filedir -d + return 0 + fi + + local -r mark_dirs=$(_rl_enabled mark-directories && echo y) + local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y) + + # we have a CDPATH, so loop on its contents + for i in ${CDPATH//:/$'\t'}; do + # create an array of matched subdirs + k="${#COMPREPLY[@]}" + for j in $( compgen -d $i/$cur ); do + if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then + j="${j}/" + fi + COMPREPLY[k++]=${j#$i/} + done + done + + _filedir -d + + if [[ ${#COMPREPLY[@]} -eq 1 ]]; then + i=${COMPREPLY[0]} + if [ "$i" == "$cur" ] && [[ $i != "*/" ]]; then + COMPREPLY[0]="${i}/" + fi + fi + + return 0 +} +if shopt -q cdable_vars; then + complete -v -F _cd $nospace $filenames cd +else + complete -F _cd $nospace $filenames cd +fi + +_remove_comp_word() +{ + if [[ COMP_CWORD -eq 0 ]]; then + return + elif [[ ${#COMP_WORDS[@]} -ge 2 ]]; then + local old_cw0="${COMP_WORDS[0]}" + local new_cw0="${COMP_WORDS[1]}" + local old_length="${#COMP_LINE}" + COMP_LINE=${COMP_LINE#${old_cw0}} + local head=${COMP_LINE:0:${#new_cw0}} + local i=1 + while [[ $head != $new_cw0 ]]; do + COMP_LINE=${COMP_LINE:1} + head=${COMP_LINE:0:${#new_cw0}} + if (( ++i > 10 )); then + break + fi + done + local new_length="${#COMP_LINE}" + COMP_POINT=$(( COMP_POINT + new_length - old_length)) + + COMP_CWORD=$(( COMP_CWORD - 1 )) + for (( i=0; i < ${#COMP_WORDS[@]} - 1; ++i )); do + COMP_WORDS[i]="${COMP_WORDS[i+1]}" + done + unset COMP_WORDS[${#COMP_WORDS[@]}-1] + else + return + fi +} + +# A meta-command completion function for commands like sudo(8), which need to +# first complete on a command, then complete according to that command's own +# completion definition - currently not quite foolproof (e.g. mount and umount +# don't work properly), but still quite useful. +# +_command() +{ + local cur func cline cspec noglob cmd done i \ + _COMMAND_FUNC _COMMAND_FUNC_ARGS + + _remove_comp_word + COMPREPLY=() + cur=`_get_cword` + # If the the first arguments following our meta-command-invoker are + # switches, get rid of them. Most definitely not foolproof. + done= + while [ -z $done ] ; do + cmd=${COMP_WORDS[0]} + if [[ "$cmd" == -* ]] && [ $COMP_CWORD -ge 1 ]; then + _remove_comp_word + elif [[ "$cmd" == -* ]] && [[ $COMP_CWORD -eq 0 ]]; then + return + else + done=1 + fi + done + + if [ $COMP_CWORD -eq 0 ]; then + COMPREPLY=( $( compgen -c -- $cur ) ) + elif complete -p $cmd &>/dev/null; then + cspec=$( complete -p $cmd ) + if [ "${cspec#* -F }" != "$cspec" ]; then + # COMP_CWORD and COMP_WORDS() are not read-only, + # so we can set them before handing off to regular + # completion routine + + # get function name + func=${cspec#*-F } + func=${func%% *} + + if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then + $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}" + else + $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" + fi + + # remove any \: generated by a command that doesn't + # default to filenames or dirnames (e.g. sudo chown) + # FIXME: I'm pretty sure this does not work! + if [ "${cspec#*-o }" != "$cspec" ]; then + cspec=${cspec#*-o } + cspec=${cspec%% *} + if [[ "$cspec" != @(dir|file)names ]]; then + COMPREPLY=("${COMPREPLY[@]//\\\\:/:}") + fi + fi + elif [ -n "$cspec" ]; then + cspec=${cspec#complete}; + cspec=${cspec%%$cmd}; + COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) ); + fi + fi + + [ ${#COMPREPLY[@]} -eq 0 ] && _filedir +} +complete -F _command $filenames nohup exec nice eval strace time ltrace then \ + else do vsound command xargs + +_root_command() +{ + PATH=/usr/gnu/bin:$PATH:/sbin:/usr/sbin _command $1 $2 $3 +} +complete -F _root_command $filenames sudo fakeroot really + +# ant(1) completion +# +have ant && { +_ant() +{ + local cur prev buildfile i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -buildfile|-f) + _filedir 'xml' + return 0 + ;; + -logfile) + _filedir + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # relevant options completion + COMPREPLY=( $( compgen -W '-help -projecthelp -version -quiet \ + -verbose -debug -emacs -logfile -logger \ + -listener -buildfile -f -D -find' -- $cur ) ) + else + # available targets completion + # find which buildfile to use + buildfile=build.xml + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == -buildfile ]]; then + buildfile=${COMP_WORDS[i+1]} + break + fi + done + [ ! -f $buildfile ] && return 0 + + # parse buildfile for targets + COMPREPLY=( $( awk -F'"' '//dev/null | \ + sed -e '1,/^-/d' -e '/^(/,$d' | \ + awk '{print $1}' | grep "^$cur" ) ) +} + +_pg_users() +{ + #COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \ + # grep "^ $cur" ) ) + #[ ${#COMPREPLY[@]} -eq 0 ] && + COMPREPLY=( $( compgen -u -- $cur ) ) +} + +# createdb(1) completion +# +_createdb() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(h|-host=)) + _known_hosts + return 0 + ;; + -@(U|-username=)) + _pg_users + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-D -T -E -h -p -U -W -e -q \ + --location= --template= --encoding= --host= --port= \ + --username= --password --echo --quiet --help' -- $cur )) + else + _pg_databases + fi +} +complete -F _createdb $default createdb + +# dropdb(1) completion +# +_dropdb() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(h|-host=)) + _known_hosts + return 0 + ;; + -@(U|-username=)) + _pg_users + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-h -p -U -W -e -q \ + --host= --port= --username= --password \ + --interactive --echo --quiet --help' -- $cur ) ) + else + _pg_databases + fi +} +complete -F _dropdb $default dropdb + +# psql(1) completion +# +_psql() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -h|--host) + _known_hosts + return 0 + ;; + -U|--username) + _pg_users + return 0 + ;; + -d|--dbname) + _pg_databases + return 0 + ;; + -@(o|f)|--output|--file) + _filedir + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # return list of available options + COMPREPLY=( $( compgen -W '-a --echo-all -A --no-align \ + -c --command -d --dbname -e --echo-queries \ + -E --echo-hidden -f --file -F --filed-separator \ + -h --host -H --html -l --list -n -o --output \ + -p --port -P --pset -q -R --record-separator \ + -s --single-step -S --single-line -t --tuples-only \ + -T --table-attr -U --username -v --variable \ + -V --version -W --password -x --expanded -X --nopsqlrc \ + -? --help ' -- $cur ) ) + else + # return list of available databases + _pg_databases + fi +} +complete -F _psql $default psql +} + +_longopt() +{ + local cur opt + + cur=`_get_cword` + + if [[ "$cur" == --*=* ]]; then + opt=${cur%%=*} + # cut backslash that gets inserted before '=' sign + opt=${opt%\\*} + cur=${cur#*=} + _filedir + COMPREPLY=( $( compgen -P "$opt=" -W '${COMPREPLY[@]}' -- $cur)) + return 0 + fi + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( $1 --help 2>&1 | sed -e '/--/!d' \ + -e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \ + command grep "^$cur" | sort -u ) ) + elif [[ "$1" == @(mk|rm)dir ]]; then + _filedir -d + else + _filedir + fi +} +# makeinfo and texi2dvi are defined elsewhere. +for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \ + bison cpio diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \ + touch vdir awk gperf grep grub indent less m4 sed shar date \ + tee who texindex cat csplit cut expand fmt fold head \ + md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \ + uniq wc ldd bash id irb mkdir rmdir; do + have $i && complete -F _longopt $filenames $i +done + +# These commands use filenames, so '-o filenames' is not needed. +for i in env netstat seq uname units wget; do + have $i && complete -F _longopt $default $i +done +unset i + +# gcc(1) completion +# +# The only unusual feature is that we don't parse "gcc --help -v" output +# directly, because that would include the options of all the other backend +# tools (linker, assembler, preprocessor, etc) without any indication that +# you cannot feed such options to the gcc driver directly. (For example, the +# linker takes a -z option, but you must type -Wl,-z for gcc.) Instead, we +# ask the driver ("g++") for the name of the compiler ("cc1"), and parse the +# --help output of the compiler. +# +have gcc && +_gcc() +{ + local cur cc backend + + COMPREPLY=() + cur=`_get_cword` + + _expand || return 0 + + case "$1" in + gcj) + backend=jc1 + ;; + gpc) + backend=gpc1 + ;; + *77) + backend=f771 + ;; + *) + backend=cc1 # (near-)universal backend + ;; + esac + + if [[ "$cur" == -* ]]; then + cc=$( $1 -print-prog-name=$backend ) + # sink stderr: + # for C/C++/ObjectiveC it's useless + # for FORTRAN/Java it's an error + COMPREPLY=( $( $cc --help 2>/dev/null | tr '\t' ' ' | \ + sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \ + command grep "^$cur" | sort -u ) ) + else + _filedir + fi +} && +complete $filenames -F _gcc gcc g++ c++ g77 gcj gpc +[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Cygwin ] && \ +[ -n "${have:-}" ] && complete $filenames -F _gcc cc + +# Linux cardctl(8) completion +# +have cardctl && +_cardctl() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W 'status config ident suspend \ + resume reset eject insert scheme' \ + -- $cur ) ) + fi +} && +complete -F _cardctl cardctl + +# This function is required by _dpkg() and _dpkg-reconfigure() +# +have dpkg && { +_comp_dpkg_installed_packages() +{ + grep -A 1 "Package: $1" /var/lib/dpkg/status | \ + grep -B 1 -E "ok installed|half-installed|unpacked| \ + half-configured|config-files" | \ + grep "Package: $1" | cut -d\ -f2 +} + +# Debian dpkg(8) completion +# +_dpkg() +{ + local cur prev i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + i=$COMP_CWORD + + _expand || return 0 + + # find the last option flag + if [[ $cur != -* ]]; then + while [[ $prev != -* && $i != 1 ]]; do + i=$((i-1)) + prev=${COMP_WORDS[i-1]} + done + fi + + case "$prev" in + -@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info|fsys-tarfile|field|control|extract))) + _filedir '?(u)deb' + return 0 + ;; + -@(b|-build)) + _filedir -d + return 0 + ;; + -@(s|p|l|-@(status|print-avail|list))) + COMPREPLY=( $( apt-cache pkgnames $cur 2>/dev/null ) ) + return 0 + ;; + -@(S|-search)) + _filedir + return 0 + ;; + -@(r|L|P|-@(remove|purge|listfiles))) + COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) ) + return 0 + ;; + *) + + COMPREPLY=( $( compgen -W '-i --install --unpack -A --record-avail \ + --configure -r --remove -P --purge --get-selections \ + --set-selections --update-avail --merge-avail \ + --clear-avail --command-fd --forget-old-unavail -s \ + --status -p --print-avail -L --listfiles -l --list \ + -S --search -C --audit --print-architecture \ + --print-gnu-build-architecture \ + --print-installation-architecture \ + --compare-versions --help --version --force-help \ + --force-all --force-auto-select --force-downgrade \ + --force-configure-any --force-hold --force-bad-path \ + --force-not-root --force-overwrite \ + --force-overwrite-diverted --force-bad-verify \ + --force-depends-version --force-depends \ + --force-confnew --force-confold --force-confdef \ + --force-confmiss --force-conflicts --force-architecture\ + --force-overwrite-dir --force-remove-reinstreq \ + --force-remove-essential -Dh \ + --debug=help --licence --admindir= --root= --instdir= \ + -O --selected-only -E --skip-same-version \ + -G --refuse-downgrade -B --auto-deconfigure \ + --no-debsig --no-act -D --debug= --status-fd \ + -b --build -I --info -f --field -c --contents \ + -x --extract -X --vextract --fsys-tarfile -e --control \ + --ignore-depends= --abort-after' -- $cur ) ) + ;; + esac + + +} +complete -F _dpkg $filenames dpkg dpkg-deb +} + +# Debian GNU dpkg-reconfigure(8) completion +# +have dpkg-reconfigure && +_dpkg_reconfigure() +{ + local cur prev opt + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + + case "$prev" in + -@(f|-frontend)) + opt=( $( echo /usr/share/perl5/Debconf/FrontEnd/* ) ) + opt=( ${opt[@]##*/} ) + opt=( ${opt[@]%.pm} ) + COMPREPLY=( $( compgen -W '${opt[@]}' -- $cur ) ) + return 0 + ;; + -@(p|-priority)) + COMPREPLY=( $( compgen -W 'low medium high critical' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-f --frontend -p --priority -a --all \ + -u --unseen-only -h --help -s --showold \ + --force --terse' -- $cur ) ) + else + COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) ) + fi +} && +complete -F _dpkg_reconfigure $default dpkg-reconfigure + +# Debian dpkg-source completion +# +have dpkg-source && +_dpkg_source() +{ + local cur prev options work i action packopts unpackopts + + packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sp -su -sr -ss -sn -sA -sK -sP -sU -sR" + unpackopts="-sp -sn -su" + options=`echo "-x -b $packopts $unpackopts" | xargs echo | sort -u | xargs echo` + + COMPREPLY=() + if [ "$1" != "dpkg-source" ]; then + exit 1 + fi + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + action="options" + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[$i]} == "-x" ]]; then + action=unpack + elif [[ ${COMP_WORDS[$i]} == "-b" ]]; then + action=pack + elif [[ ${COMP_WORDS[$i]} == "-h" ]]; then + action=help + fi + done + # if currently seeing a complete option, return just itself. + for i in $options; do + if [ "$cur" = "$i" ]; then + COMPREPLY=( "$cur" ) + return 0 + fi + done + case "$action" in + "unpack") + if [ "$cur" = "-" -o "$cur" = "-s" ]; then + COMPREPLY=( $unpackots ) + return 0 + fi + case "$prev" in + "-x") + COMPREPLY=( $( compgen -d -- "$cur" ) \ + $( compgen -f -X '!*.dsc' -- "$cur" ) ) + return 0 + ;; + *) + COMPREPLY=( $unpackopts $(compgen -d -f -- "$cur" ) ) + return 0 + ;; + esac + return 0 + ;; + "pack") + if [ "$cur" = "-" ]; then + COMPREPLY=( $packopts ) + return 0 + fi + if [ "$cur" = "-s" ]; then + COMPREPLY=( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \ + "-sA" "-sK" "-sP" "-sU" "-sR" ) + return 0 + fi + case "$prev" in + "-b") + COMPREPLY=( $( compgen -d -- "$cur" ) ) + return 0 + ;; + "-c"|"-l"|"-T"|"-i"|"-I") + # -c: get controlfile + # -l: get per-version info from this file + # -T: read variables here, not debian/substvars + # -i: filter out files to ignore diffs of. + # -I: filter out files when building tarballs. + # return directory names and file names + COMPREPLY=( $( compgen -d -f ) ) + return 0 + ;; + "-F") + # -F: force change log format + COMPREPLY=( $( ( cd /usr/lib/dpkg/parsechangelog; compgen -f "$cur" ) ) ) + return 0 + ;; + "-V"|"-D") + # -V: set a substitution variable + # we don't know anything about possible variables or values + # so we don't try to suggest any completion. + COMPREPLY=() + return 0 + ;; + "-D") + # -D: override or add a .dsc field and value + # if $cur doesn't contain a = yet, suggest variable names + if echo -- "$cur" | grep -q "="; then + # $cur contains a "=" + COMPREPLY=() + return 0 + else + COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files ) + return 0 + fi + ;; + "-U") + # -U: remove a field + # Suggest possible fieldnames + COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files ) + return 0 + ;; + *) + COMPREPLY=( $packopts ) + return 0 + ;; + esac + return 0 + ;; + *) + # if seeing a partial option, return possible completions. + if [ "$cur" = "-s" ]; then + COMPREPLY=( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \ + "-sA" "-sK" "-sP" "-sU" "-sR" ) + return 0 + fi + # else return all possible options. + COMPREPLY=( $options ) + return 0 + ;; + esac +} && +complete -F _dpkg_source dpkg-source + +# Debian Linux dselect(8) completion. +# +have dselect && +_dselect() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + --admindir) + _filedir -d + return 0 + ;; + + -@(D|debug)) + _filedir + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--admindir --help --version --licence \ + --license --expert --debug' -- $cur ) ) + else + COMPREPLY=( $( compgen -W 'access update select install config \ + remove quit' -- $cur ) ) + fi + + + return 0 +} && +complete -F _dselect $filenames dselect + +# Java completion +# + +# available path elements completion +have java && { +_java_path() +{ + cur=${cur##*:} + _filedir '@(jar|zip)' +} + +# exact classpath determination +_java_find_classpath() +{ + local i + + # search first in current options + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == -@(cp|classpath) ]]; then + classpath=${COMP_WORDS[i+1]} + break + fi + done + + # default to environment + [ -z "$classpath" ] && classpath=$CLASSPATH + + # default to current directory + [ -z "$classpath" ] && classpath=. +} + +# exact sourcepath determination +_java_find_sourcepath() +{ + local i + + # search first in current options + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == -sourcepath ]]; then + sourcepath=${COMP_WORDS[i+1]} + break + fi + done + + # default to classpath + [ -z "$sourcepath" ] && _java_find_classpath + sourcepath=$classpath +} + +# available classes completion +_java_classes() +{ + local classpath i + + # find which classpath to use + _java_find_classpath + + # convert package syntax to path syntax + cur=${cur//.//} + # parse each classpath element for classes + for i in ${classpath//:/ }; do + if [ -r $i ] && [[ "$i" == *.@(jar|zip) ]]; then + if type zipinfo &> /dev/null; then + COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \ + "$i" | grep "^$cur" | grep '\.class$' | \ + grep -v "\\$" ) ) + else + COMPREPLY=( "${COMPREPLY[@]}" $( jar tf "$i" \ + "$cur" | grep "\.class$" | grep -v "\\$" ) ) + fi + + elif [ -d $i ]; then + i=${i%/} + COMPREPLY=( "${COMPREPLY[@]}" $( find "$i" -type f \ + -path "$i/$cur*.class" 2>/dev/null | \ + grep -v "\\$" | sed -e "s|^$i/||" ) ) + fi + done + + # remove class extension + COMPREPLY=( ${COMPREPLY[@]%.class} ) + # convert path syntax to package syntax + COMPREPLY=( ${COMPREPLY[@]//\//.} ) +} + +# available packages completion +_java_packages() +{ + local sourcepath i + + # find wich sourcepath to use + _java_find_sourcepath + + # convert package syntax to path syntax + cur=${cur//.//} + # parse each sourcepath element for packages + for i in ${sourcepath//:/ }; do + if [ -d $i ]; then + COMPREPLY=( "${COMPREPLY[@]}" $( command ls -F -d \ + $i/$cur* 2>/dev/null | sed -e 's|^'$i'/||' ) ) + fi + done + # keep only packages + COMPREPLY=( $( echo "${COMPREPLY[@]}" | tr " " "\n" | grep "/$" ) ) + # remove packages extension + COMPREPLY=( ${COMPREPLY[@]%/} ) + # convert path syntax to package syntax + cur=${COMPREPLY[@]//\//.} +} + +# java completion +# +_java() +{ + local cur prev i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + for ((i=1; i < $COMP_CWORD; i++)); do + case ${COMP_WORDS[$i]} in + -cp|-classpath) + ((i++)) # skip the classpath string. + ;; + -*) + # this is an option, not a class/jarfile name. + ;; + *) + # once we've seen a class, just do filename completion + _filedir + return 0 + ;; + esac + done + + case $prev in + -@(cp|classpath)) + _java_path + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # relevant options completion + COMPREPLY=( $( compgen -W '-client -hotspot -server -classic \ + -cp -classpath -D -verbose -verbose:class \ + -verbose:gc -version:jni -version \ + -showversion -? -help -X -jar \ + -ea -enableassertions -da -disableassertions \ + -esa -enablesystemassertions \ + -dsa -disablesystemassertions ' -- $cur ) ) + else + if [[ "$prev" == -jar ]]; then + # jar file completion + _filedir jar + else + # classes completion + _java_classes + fi + fi +} +complete -F _java $filenames java +} + +# javadoc completion +# +have javadoc && +_javadoc() +{ + COMPREPLY=() + local cur prev + + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + -@(overview|helpfile|stylesheetfile)) + _filedir + return 0 + ;; + -d) + _filedir -d + return 0 + ;; + -@(classpath|bootclasspath|docletpath|sourcepath|extdirs)) + _java_path + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # relevant options completion + COMPREPLY=( $( compgen -W '-overview -public -protected \ + -package -private -help -doclet -docletpath \ + -sourcepath -classpath -exclude -subpackages \ + -breakiterator -bootclasspath -source -extdirs \ + -verbose -locale -encoding -J -d -use -version \ + -author -docfilessubdirs -splitindex \ + -windowtitle -doctitle -header -footer -bottom \ + -link -linkoffline -excludedocfilessubdir \ + -group -nocomment -nodeprecated -noqualifier \ + -nosince -nodeprecatedlist -notree -noindex \ + -nohelp -nonavbar -quiet -serialwarn -tag \ + -taglet -tagletpath -charset -helpfile \ + -linksource -stylesheetfile -docencoding' -- \ + $cur ) ) + else + # source files completion + _filedir java + # packages completion + _java_packages + fi +} && +complete -F _javadoc $filenames javadoc + +# javac completion +# +have javac && +_javac() +{ + COMPREPLY=() + local cur prev + + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + -d) + _filedir -d + return 0 + ;; + -@(classpath|bootclasspath|sourcepath|extdirs)) + _java_path + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # relevant options completion + COMPREPLY=( $( compgen -W '-g -g:none -g:lines -g:vars\ + -g:source -O -nowarn -verbose -deprecation -classpath\ + -sourcepath -bootclasspath -extdirs -d -encoding -source\ + -target -help' -- $cur ) ) + else + # source files completion + _filedir java + fi +} && +complete -F _javac $filenames javac + +# PINE address-book completion +# +have pine && +_pineaddr() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook 2>/dev/null)' \ + -- $cur ) ) +} && +complete -F _pineaddr $default pine + +# mutt completion +# +# Mutt doesn't have an "addressbook" like Pine, but it has aliases and +# a "query" function to retrieve addresses, so that's what we use here. +have mutt || have muttng && { +_muttaddr() +{ + _muttaliases + _muttquery + return 0 +} + +_muttconffiles() +{ + local file sofar + local -a newconffiles + + sofar=" $1 " + shift + while [[ "$1" ]]; do + newconffiles=( $(sed -rn 's|^source[[:space:]]+([^[:space:]]+).*$|\1|p' $(eval echo $1) ) ) + for file in "${newconffiles[@]}"; do + [[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] && + continue + sofar="$sofar $file" + sofar=" $(eval _muttconffiles \"$sofar\" $file) " + done + shift + done + echo $sofar +} + +_muttaliases() +{ + local cur muttrc + local -a conffiles aliases + cur=`_get_cword` + + [ -f ~/.${muttcmd}/${muttcmd}rc ] && muttrc="~/.${muttcmd}/${muttcmd}rc" + [ -f ~/.${muttcmd}rc ] && muttrc="~/.${muttcmd}rc" + [ -z "$muttrc" ] && return 0 + + conffiles=( $(eval _muttconffiles $muttrc $muttrc) ) + aliases=( $( sed -rn 's|^alias[[:space:]]+([^[:space:]]+).*$|\1|p' \ + $(eval echo "${conffiles[@]}") ) ) + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- $cur ) ) + + return 0 +} + +_muttquery() +{ + local cur querycmd + local -a queryresults + cur=`_get_cword` + + querycmd="$( $muttcmd -Q query_command | sed -r 's|^query_command=\"(.*)\"$|\1|; s|%s|'$cur'|' )" + if [ -z "$cur" -o -z "$querycmd" ]; then + queryresults=() + else + queryresults=( $( $querycmd | \ + sed -nr '2,$s|^([^[:space:]]+).*|\1|p' ) ) + fi + + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}" \ + -- $cur ) ) + + return 0 +} + +_muttfiledir() +{ + local cur folder spoolfile + cur=`_get_cword` + + # This is currently not working so well. Perhaps this function should + # just call _filedir() for the moment. + if [[ $cur == [=+]* ]]; then + folder="$( $muttcmd -Q folder | sed -r 's|^folder=\"(.*)\"$|\1|' )" + : folder:=~/Mail + + # Match any file in $folder beginning with $cur + # (minus the leading '=' sign). + COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) ) + COMPREPLY=( ${COMPREPLY[@]#$folder/} ) + return 0 + elif [ "$cur" == !* ]; then + spoolfile="$( $muttcmd -Q spoolfile | sed -r 's|^spoolfile=\"(.*)\"$|\1|' )" + [ ! -z "$spoolfile" ] && eval cur="${cur/^!/$spoolfile}"; + fi + _filedir + + return 0 +} + +_mutt() +{ + local cur prev + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + COMPREPLY=() + + [ ${COMP_WORDS[0]} == muttng ] && muttcmd="muttng" || muttcmd="mutt" + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \ + -p -Q -R -s -v -x -y -z -Z -h' \ + -- $cur ) ) + return 0 + ;; + *) + case "$prev" in + -@(a|f|F|H|i)) + _muttfiledir + return 0 + ;; + -A) + _muttaliases + return 0 + ;; + -@(e|m|Q|s|h|p|R|v|y|z|Z)) + return 0 + ;; + *) + _muttaddr + return 0 + ;; + esac + ;; + esac + +} +complete -F _mutt $default $filenames mutt muttng +} + +_configure_func() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + # if $COMP_CONFIGURE_HINTS is not null, then completions of the form + # --option=SETTING will include 'SETTING' as a contextual hint + [[ "$cur" != -* ]] && return 0 + + if [ -n "$COMP_CONFIGURE_HINTS" ]; then + COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' | grep ^$cur ) ) + + else + COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' | grep ^$cur ) ) + fi +} +complete -F _configure_func $default configure + +# Debian reportbug(1) completion +# +have reportbug && +_reportbug() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -f|--filename|-i|--include|--mta|-o|--output) + _filedir + return 0 + ;; + -B|--bts) + COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \ + $cur )) + return 0 + ;; + -e|--editor|--mua) + COMP_WORDS=(COMP_WORDS[0] $cur) + COMP_CWORD=1 + _command + return 0 + ;; + --mode) + COMPREPLY=( $( compgen -W "novice standard expert" -- $cur ) ) + return 0 + ;; + -S|--severity) + COMPREPLY=( $( compgen -W "grave serious important normal \ + minor wishlist" -- $cur ) ) + return 0 + ;; + -u|--ui|--interface) + COMPREPLY=( $( compgen -W "newt text gnome" -- $cur ) ) + return 0 + ;; + -t|--type) + COMPREPLY=( $( compgen -W "gnats debbugs" -- $cur ) ) + return 0 + ;; + -T|--tags) + COMPREPLY=( $( compgen -W "none patch security upstream sid \ + woody potato sarge fixed" -- $cur )) + return 0 + ;; + *) + ;; + esac + + COMPREPLY=($( compgen -W '-h --help -v --version -a --af -b \ + --no-query-bts --query-bts -B --bts -c --configure \ + --no-config-files --check-available -d --debug \ + --no-check-available -e --editor --email -f \ + --filename -g --gnupg -H --header -i --include -j \ + --justification -l --ldap --no-ldap -L --list-cc -m \ + --maintonly --mode --mua --mta --mutt -n --mh --nmh \ + -o --output -p --print -P --pgp --proxy --http_proxy\ + -q --quiet -Q --query-only --realname --report-quiet \ + --reply-to --replyto -s --subject -S --severity \ + --smtphost -t --type -T --tags --template -V -x \ + --no-cc --package-version -z --no-compress \ + --ui --interface -u \ + wnpp boot-floppies kernel-image' -- $cur ) \ + $( apt-cache pkgnames -- $cur 2> /dev/null ) ) + _filedir + return 0 +} && +complete -F _reportbug $filenames reportbug + +# Debian querybts(1) completion +# +have querybts && +_querybts() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -B|--bts) + COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \ + $cur )) + return 0 + ;; + -u|--ui|--interface) + COMPREPLY=($( compgen -W "newt text gnome" -- $cur )) + return 0 + ;; + *) + ;; + esac + + COMPREPLY=($( compgen -W '-h --help -v --version -A --archive \ + -B --bts -l --ldap --no-ldap --proxy= --http_proxy= \ + -s --source -w --web -u --ui --interface \ + wnpp boot-floppies' -- $cur ) \ + $( apt-cache pkgnames -- $cur 2> /dev/null ) ) +} && +complete -F _querybts $filenames querybts + +# update-alternatives completion +# +have update-alternatives && { +installed_alternatives() +{ + local admindir + # find the admin dir + for i in alternatives dpkg/alternatives rpm/alternatives; do + [ -d /var/lib/$i ] && admindir=/var/lib/$i && break + done + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == --admindir ]]; then + admindir=${COMP_WORDS[i+1]} + break + fi + done + COMPREPLY=( $( command ls $admindir | grep "^$cur" ) ) +} + +_update_alternatives() +{ + local cur prev mode args i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + --@(altdir|admindir)) + _filedir -d + return 0 + ;; + --@(help|version)) + return 0 + ;; + esac + + # find wich mode to use and how many real args used so far + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all) ]]; then + mode=${COMP_WORDS[i]} + args=$(($COMP_CWORD - i)) + break + fi + done + + case $mode in + --install) + case $args in + 1) + _filedir + ;; + 2) + installed_alternatives + ;; + 3) + _filedir + ;; + esac + ;; + --remove) + case $args in + 1) + installed_alternatives + ;; + 2) + _filedir + ;; + esac + ;; + --auto) + installed_alternatives + ;; + --remove-all) + installed_alternatives + ;; + --display) + installed_alternatives + ;; + --config) + installed_alternatives + ;; + *) + COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \ + --altdir --admindir' -- $cur ) \ + $( compgen -W '--install --remove --auto --display \ + --config' -- $cur ) ) + esac +} +complete -F _update_alternatives update-alternatives +} + +# Python completion +# +have python && +_python() +{ + local prev cur + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]##*/} + + case "$prev" in + -Q) + COMPREPLY=( $( compgen -W "old new warn warnall" -- $cur ) ) + return 0 + ;; + -W) + COMPREPLY=( $( compgen -W "ignore default all module once error" -- $cur ) ) + return 0 + ;; + -c) + _filedir '@(py|pyc|pyo)' + return 0 + ;; + !(python|-?)) + [[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] && _filedir + ;; + esac + + + # if '-c' is already given, complete all kind of files. + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == -c ]]; then + _filedir + fi + done + + + if [[ "$cur" != -* ]]; then + _filedir '@(py|pyc|pyo)' + else + COMPREPLY=( $( compgen -W "- -d -E -h -i -O -Q -S -t -u \ + -U -v -V -W -x -c" -- $cur ) ) + fi + + + + return 0 +} && +complete -F _python $filenames python + +# Perl completion +# +have perl && +{ +_perlmodules() +{ + COMPREPLY=( $( compgen -P "$prefix" -W "$( perl -e 'sub mods { my ($base,$dir)=@_; return if $base !~ /^\Q$ENV{cur}/; chdir($dir) or return; for (glob(q[*.pm])) {s/\.pm$//; print qq[$base$_\n]}; mods(/^(?:[.\d]+|$Config{archname}-$Config{osname}|auto)$/ ? undef : qq[${base}${_}\\\\:\\\\:],qq[$dir/$_]) for grep {-d} glob(q[*]); } mods(undef,$_) for @INC;' )" -- $cur ) ) +} + +_perl() +{ + local cur prev prefix temp + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + prefix="" + + # completing an option (may or may not be separated by a space) + if [[ "$cur" == -?* ]]; then + temp=$cur + prev=${temp:0:2} + cur=${temp:2} + prefix=$prev + fi + + # only handle module completion for now + case "$prev" in + -I|-x) + COMPREPLY=( $( compgen -d -P "$prev" -- "$cur" ) ) + return 0 + ;; + -m|-M) + _perlmodules + return 0 + ;; + esac + + # handle case where first parameter is not a dash option + if [[ "${COMP_WORDS[COMP_CWORD]}" != -* ]]; then + _filedir + return 0 + fi + + # complete using basic options + COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \ + -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) ) + return 0 +} +complete -F _perl $filenames perl + +_perldoc() +{ + local cur prev prefix temp + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + prefix="" + + # completing an option (may or may not be separated by a space) + if [[ "$cur" == -?* ]]; then + temp=$cur + prev=${temp:0:2} + cur=${temp:2} + prefix=$prev + fi + + # complete builtin perl functions + case $prev in + -f) + COMPREPLY=( $( compgen -W 'chomp chop chr crypt hex index lc \ + lcfirst length oct ord pack q qq reverse rindex sprintf \ + substr tr uc ucfirst y m pos quotemeta s split study qr abs \ + atan2 cos exp hex int log oct rand sin sqrt srand pop push \ + shift splice unshift grep join map qw reverse sort unpack \ + delete each exists keys values binmode close closedir \ + dbmclose dbmopen die eof fileno flock format getc print \ + printf read readdir rewinddir seek seekdir select syscall \ + sysread sysseek syswrite tell telldir truncate warn write \ + pack read syscall sysread syswrite unpack vec -X chdir chmod \ + chown chroot fcntl glob ioctl link lstat mkdir open opendir \ + readlink rename rmdir stat symlink umask unlink utime caller \ + continue do dump eval exit goto last next redo return \ + sub wantarray caller import local my our package use defined \ + formline reset scalar undef \ + alarm exec fork getpgrp getppid getpriority kill pipe qx \ + setpgrp setpriority sleep system times wait waitpid \ + import no package require use bless dbmclose dbmopen package \ + ref tie tied untie use accept bind connect getpeername \ + getsockname getsockopt listen recv send setsockopt shutdown \ + socket socketpair msgctl msgget msgrcv msgsnd semctl semget \ + semop shmctl shmget shmread shmwrite endgrent endhostent \ + endnetent endpwent getgrent getgrgid getgrnam getlogin \ + getpwent getpwnam getpwuid setgrent setpwent endprotoent \ + endservent gethostbyaddr gethostbyname gethostent \ + getnetbyaddr getnetbyname getnetent getprotobyname \ + getprotobynumber getprotoent getservbyname getservbyport \ + getservent sethostent setnetent setprotoent setservent \ + gmtime localtime time times' -- $cur ) ) + return 0 + ;; + esac + + case $cur in + -*) + COMPREPLY=( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur )) + return 0 + ;; + */*) + return 0 + ;; + *) + _perlmodules + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=cat man perl 2>/dev/null | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ) ) + + return 0 + ;; + esac +} +complete -F _perldoc $default perldoc +} + +# rcs(1) completion +# +have rcs && +_rcs() +{ + local cur prev file dir i + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + file=${cur##*/} + dir=${cur%/*} + + # deal with relative directory + [ "$file" = "$dir" ] && dir=. + + COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) ) + + for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do + file=${COMPREPLY[$i]##*/} + dir=${COMPREPLY[$i]%RCS/*} + COMPREPLY[$i]=$dir$file + done + + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -G "$dir/$file*,v" ) ) + + for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do + COMPREPLY[$i]=${COMPREPLY[$i]%,v} + done + + # default to files if nothing returned and we're checking in. + # otherwise, default to directories + [ ${#COMPREPLY[@]} -eq 0 -a $1 = ci ] && _filedir || _filedir -d +} && +complete -F _rcs $filenames ci co rlog rcs rcsdiff + +# lilo(8) completion +# +have lilo && { +_lilo_labels() +{ + COMPREPLY=( $( awk -F'=' '/label/ {print $2}' \ + /etc/lilo.conf | sed -e 's/"//g' | grep "^$cur" ) ) +} + +_lilo() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + -@(C|i|m|s|S)) + _filedir + return 0 + ;; + -r) + _filedir -d + return 0 + ;; + -@(I|D|R)) + # label completion + _lilo_labels + return 0 + ;; + -@(A|b|M|u|U)) + # device completion + cur=${cur:=/dev/} + _filedir + return 0 + ;; + -T) + # topic completion + COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= \ + table= video' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # relevant options completion + COMPREPLY=( $( compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m \ + -M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- \ + $cur ) ) + fi +} +complete -F _lilo lilo +} + +# links completion +# +have links && +_links() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + case "$cur" in + --*) + COMPREPLY=( $( compgen -W '--help' -- $cur ) ) + ;; + -*) + COMPREPLY=( $( compgen -W '-async-dns -max-connections \ + -max-connections-to-host -retries \ + -receive-timeout -unrestartable-receive-timeout\ + -format-cache-size -memory-cache-size \ + -http-proxy -ftp-proxy -download-dir \ + -assume-codepage -anonymous -dump -no-connect \ + -source -version -help' -- $cur ) ) + ;; + *) + if [ -r ~/.links/links.his ]; then + COMPREPLY=( $( compgen -W '$( < ~/.links/links.his )' \ + -- $cur ) ) + fi + _filedir '@(htm|html)' + return 0 + ;; + esac + + return 0 +} && +complete -F _links $filenames links + +[ $UNAME = FreeBSD ] && { +# FreeBSD package management tool completion +# +_pkg_delete() +{ + local cur pkgdir prev + + pkgdir=${PKG_DBDIR:-/var/db/pkg}/ + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + [ "$prev" = "-o" -o "$prev" = "-p" -o "$prev" = "-W" ] && return 0 + + COMPREPLY=( $( compgen -d $pkgdir$cur ) ) + COMPREPLY=( ${COMPREPLY[@]#$pkgdir} ) + + return 0 +} +complete -F _pkg_delete $dirnames pkg_delete pkg_info +have pkg_deinstall && complete -F _pkg_delete $dirnames pkg_deinstall + +# FreeBSD kernel module commands +# +_kldload() +{ + local cur moddir + + moddir=/modules/ + [ -d $moddir ] || moddir=/boot/kernel/ + cur=`_get_cword` + + COMPREPLY=( $( compgen -f $moddir$cur ) ) + COMPREPLY=( ${COMPREPLY[@]#$moddir} ) + COMPREPLY=( ${COMPREPLY[@]%.ko} ) + + return 0 +} +complete -F _kldload $filenames kldload + +_kldunload() +{ + local cur + cur=`_get_cword` + COMPREPLY=( $(kldstat | sed -ne "s/^.*[ \t]\+\($cur[a-z_]\+\).ko$/\1/p") ) +} +complete -F _kldunload $filenames kldunload +} + +# FreeBSD portupgrade completion +# +have portupgrade && +_portupgrade() +{ + local cur pkgdir prev + + pkgdir=${PKG_DBDIR:-/var/db/pkg}/ + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + [ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0 + + COMPREPLY=( $( compgen -d $pkgdir$cur ) ) + COMPREPLY=( ${COMPREPLY[@]#$pkgdir} ) + COMPREPLY=( ${COMPREPLY[@]%-*} ) + + return 0 +} && +complete -F _portupgrade $dirnames portupgrade + +# FreeBSD portinstall completion +# +have portinstall && +_portinstall() +{ + local cur portsdir prev indexfile + local -a COMPREPLY2 + + portsdir=${PORTSDIR:-/usr/ports}/ + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + # First try INDEX-5 + indexfile=$portsdir/INDEX-5 + # Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x + [ "${OSTYPE%.*}" = "freebsd5" -a -f $indexfile ] || + indexfile=$portsdir/INDEX + + [ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0 + + COMPREPLY=( $( egrep "^$cur" < $indexfile | cut -d'|' -f1 ) ) + COMPREPLY2=( $( egrep "^[^\|]+\|$portsdir$cur" < $indexfile | \ + cut -d'|' -f2 ) ) + COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} ) + COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" ) + + return 0 +} && +complete -F _portinstall $dirnames portinstall + +# Slackware Linux removepkg completion +# +have removepkg && [ -f /etc/slackware-version ] && +_removepkg() +{ + local packages cur + + COMPREPLY=() + cur=`_get_cword` + + COMPREPLY=( $( (cd /var/log/packages; compgen -f -- "$cur") ) ) +} && +complete -F _removepkg $filenames removepkg && + complete $dirnames -f -X '!*.tgz' installpkg upgradepkg explodepkg + +# look(1) completion +# +have look && +_look() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD = 1 ]; then + COMPREPLY=( $( compgen -W '$(look $cur)' ) ) + fi +} && +complete -F _look $default look + +# ypcat(1) and ypmatch(1) completion +# +have ypmatch && +_ypmatch() +{ + local cur map + + COMPREPLY=() + cur=`_get_cword` + + [ $1 = ypcat ] && [ $COMP_CWORD -gt 1 ] && return 0 + [ $1 = ypmatch ] && [ $COMP_CWORD -gt 2 ] && return 0 + + if [ $1 = ypmatch ] && [ $COMP_CWORD -eq 1 ] && \ + [ ${#COMP_WORDS[@]} -eq 3 ]; then + map=${COMP_WORDS[2]} + COMPREPLY=( $( compgen -W '$( ypcat $map | \ + cut -d':' -f 1 )' -- $cur) ) + else + [ $1 = ypmatch ] && [ $COMP_CWORD -ne 2 ] && return 0 + COMPREPLY=( $( compgen -W \ + '$( echo $(ypcat -x | cut -d"\"" -f 2))' -- $cur)) + fi + + return 0 +} && +complete -F _ypmatch ypmatch ypcat + +# mplayer(1) completion +# +have mplayer && { +_mplayer_options_list() +{ + cur=${cur%\\} + COMPREPLY=( $( $1 $2 help 2> /dev/null | \ + sed -e '1,/^Available/d' | awk '{print $1}' | \ + sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' | \ + grep "^$cur" ) ) +} + +_mplayer() +{ + local cmd cur prev skinsdir IFS=$' \t\n' i j k=0 + + COMPREPLY=() + cmd=${COMP_WORDS[0]} + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(ac|afm|vc|vfm|ao|vo|vop|fstype)) + _mplayer_options_list mplayer $prev + return 0 + ;; + -@(oac|ovc|of)) + _mplayer_options_list mencoder $prev + return 0 + ;; + -audiofile) + _filedir '@(mp3|MP3|mpg|MPG|ogg|OGG|wav|WAV|mid|MID|flac|FLAC|mka|MKA)' + return 0 + ;; + -font) + _filedir '@(desc|ttf)' + return 0 + ;; + -sub) + _filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js|ssa|SSA|aas|AAS)' + return 0 + ;; + -vobsub) + _filedir '@(idx|IDX|ifo|IFO|sub|SUB)' + IFS=$'\t\n' + COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do + if [ -f $i -a -r $i ]; then + echo ${i%.*} + else + echo $i + fi + done ) ) + IFS=$' \t\n' + return 0 + ;; + -ifo) + _filedir '@(ifo|IFO)' + return 0 + ;; + -cuefile) + _filedir '@(bin|BIN|cue|CUE)' + return 0 + ;; + -skin) + # if you don't have installed mplayer in /usr you + # may want to set the MPLAYER_SKINS_DIR global variable + if [ -n "$MPLAYER_SKINS_DIR" ]; then + skinsdir=$MPLAYER_SKINS_DIR + else + skinsdir=/usr/share/mplayer/Skin + fi + + IFS=$'\t\n' + for i in ~/.mplayer/Skin $skinsdir; do + if [ -d $i -a -r $i ]; then + for j in $( compgen -d $i/$cur ); do + COMPREPLY[$k]=${j#$i/} + k=$((++k)) + done + fi + done + IFS=$' \t\n' + return 0 + ;; + -@(mixer|@(cdrom|dvd)-device|dvdauth|fb|zrdev)) + cur=${cur:=/dev/} + _filedir + return 0 + ;; + -@(edl?(out)|lircconf|menu-cfg|playlist|csslib|dumpfile)| \ + -@(subfile|vobsub|aofile|fbmodeconfig|include|o|dvdkey)| \ + -passlogfile) + _filedir + return 0 + ;; + -@(auto@(q|sync)|loop|menu-root|speed|sstep|aid|alang)| \ + -@(?(@(audio|sub)-)demuxer|bandwidth|cache|chapter)| \ + -@(dvd?(angle)|fps|frames|mc|passwd|user|sb|srate|ss|vcd)| \ + -@(vi?(d|vo)|ffactor|sid|slang|spu@(align|aa|gauss))| \ + -@(vobsubid|delay|bpp|brightness|contrast|dfbopts|display)| \ + -@(fbmode|geometry|guiwid|hue|icelayer|screen[wh]|wid)| \ + -@(monitor@(aspect|-@(dotclock|[hv]freq))|panscan|saturation)| \ + -@(xineramascreen|zr@(crop|norm|quality|[xy]doff|[vh]dec))| \ + -@(aspect|pp|x|y|xy|z|stereo|audio-@(density|delay|preload))| \ + -@(endpos|osdlevel|ffourcc|sws|channels|skiplimit|format)| \ + -@(ofps|aa@(driver|@(osd|sub)color)|vobsubout?(i@(ndex|d)))| \ + -sub@(-bg-@(alpha|color)|cp|delay|fps|pos|align|width)| \ + -sub@(font-@(blur|outline|autoscale|encoding|@(osd|text)-scale))) + return 0 + ;; + -lavdopts) + COMPREPLY=( $( compgen -W 'ec er= bug= idct= gray' \ + -- $cur ) ) + return 0 + ;; + -lavcopts) + COMPREPLY=( $( compgen -W 'vcodec= vqmin= vqscale= \ + vqmax= mbqmin= mbqmax= vqdiff= \ + vmax_b_frames= vme= vhq v4mv \ + keyint= vb_strategy= vpass= \ + aspect= vbitrate= vratetol= \ + vrc_maxrate= vrc_minrate= \ + vrc_buf_size= vb_qfactor= vi_qfactor= \ + vb_qoffset= vi_qoffset= vqblur= \ + vqcomp= vrc_eq= vrc_override= \ + vrc_init_cplx= vqsquish= vlelim= \ + vcelim= vstrict= vdpart vpsize= gray \ + vfdct= idct= lumi_mask= dark_mask= \ + tcplx_mask= scplx_mask= naq ildct \ + format= pred qpel precmp= cmp= \ + subcmp= predia= dia= trell last_pred= \ + preme= subq= psnr mpeg_quant aic umv' \ + -- $cur ) ) + return 0 + ;; + -ssf) + COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= \ + cvs=' -- $cur ) ) + return 0 + ;; + -jpeg) + COMPREPLY=( $( compgen -W 'noprogressive progressive \ + nobaseline baseline optimize= \ + smooth= quality= outdir=' -- $cur ) ) + return 0 + ;; + -xvidopts) + COMPREPLY=( $( compgen -W 'dr2 nodr2' -- $cur ) ) + return 0 + ;; + -xvidencopts) + COMPREPLY=( $( compgen -W 'pass= bitrate= \ + fixed_quant= me_quality= 4mv \ + rc_reaction_delay_factor= \ + rc_averaging_period= rc_buffer= \ + quant_range= min_key_interval= \ + max_key_interval= mpeg_quant \ + mod_quant lumi_mask hintedme \ + hintfile debug keyframe_boost= \ + kfthreshold= kfreduction=' -- $cur ) ) + return 0 + ;; + -divx4opts) + COMPREPLY=( $( compgen -W 'br= key= deinterlace q= \ + min_quant= max_quant= rc_period= \ + rc_reaction_period= crispness= \ + rc_reaction_ratio= pass= vbrpass= \ + help' -- $cur ) ) + return 0 + ;; + -info) + COMPREPLY=( $( compgen -W 'name= artist= genre= \ + subject= copyright= srcform= \ + comment= help' -- $cur ) ) + return 0 + ;; + -lameopts) + COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= \ + ratio= vol= mode= padding= fast \ + preset= help' -- $cur ) ) + return 0 + ;; + -rawaudio) + COMPREPLY=( $( compgen -W 'on channels= rate= \ + samplesize= format=' -- $cur ) ) + return 0 + ;; + -rawvideo) + COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif \ + 4cif pal ntsc w= h= y420 yv12 yuy2 \ + y8 format= size=' -- $cur ) ) + return 0 + ;; + -aop) + COMPREPLY=( $( compgen -W 'list= delay= format= fout= \ + volume= mul= softclip' -- $cur ) ) + return 0 + ;; + -dxr2) + COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded \ + iec958-decoded mute ucode= 75ire bw \ + color interlaced macrovision= norm= \ + square-pixel ccir601-pixel cr-left= \ + cr-right= cr-top= cr-bot= ck-rmin= \ + ck-gmin= ck-bmin= ck-rmax= ck-gmax= \ + ck-bmax= ck-r= ck-g= ck-b= \ + ignore-cache= ol-osd= olh-cor= \ + olw-cor= olx-cor= oly-cor= overlay \ + overlay-ratio= update-cache' -- $cur )) + return 0 + ;; + -tv) + COMPREPLY=( $( compgen -W 'on noaudio driver= device= \ + input= freq= outfmt= width= height= \ + buffersize= norm= channel= chanlist= \ + audiorate= forceaudio alsa amode= \ + forcechan= adevice= audioid= volume= \ + bass= treble= balance= fps= \ + channels= immediatemode=' -- $cur ) ) + return 0 + ;; + -mf) + COMPREPLY=( $( compgen -W 'on w= h= fps= type=' \ + -- $cur ) ) + return 0 + ;; + -cdda) + COMPREPLY=( $( compgen -W 'speed= paranoia= \ + generic-dev= sector-size= overlap= \ + toc-bias toc-offset= skip noskip' \ + -- $cur ) ) + return 0 + ;; + -input) + COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate \ + keylist cmdlist js-dev file' -- $cur ) ) + return 0 + ;; + -af) + COMPREPLY=( $( compgen -W 'resample resample= \ + channels channels= format format= \ + volume volume= delay delay= pan \ + pan= sub sub= surround surround=' \ + -- $cur ) ) + return 0 + ;; + -af-adv) + COMPREPLY=( $( compgen -W 'force= list=' -- $cur ) ) + return 0 + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W '-aid -alang -audio-demuxer \ + -audiofile -cdrom-device -cache -cdda \ + -channels -chapter -csslib -demuxer \ + -dvd -dvd-device -dvdangle -dvdauth \ + -dvdkey -dvdnav -forceidx -fps -frames \ + -hr-mp3-seek -idx -mc -mf -ni -nobps \ + -passwd -rawaudio -rtsp-stream-over-tcp\ + -skipopening -sb -srate -ss -tv -user \ + -vcd -vid -vivo -ifo -ffactor -font \ + -noautosub -nooverlapsub -sid -slang \ + -sub -subcc -subcp -sub-demuxer \ + -subdelay -subfont-autoscale \ + -subfont-blur -subfont-encoding \ + -subfont-osd-scale -subfont-outline \ + -subfont-text-scale -subfps -subfile \ + -subpos -unicode -utf8 -vobsub \ + -vobsubid -ac -afm -aspect -flip \ + -lavdopts -noaspect -nosound -pp -ssf \ + -stereo -sws -vc -vfm -vop -xvidopts\ + -xy -zoom -bandwidth -cuefile \ + -noextbased -rawvideo -overlapsub \ + -sub-bg-alpha -sub-bg-color -subalign \ + -subwidth -sub-no-text-pp -spualign \ + -spuaa -spugauss -pphelp -verbose -v \ + -noni -noidx -nohr-mp3-seek -extbased \ + -bps -oldpp -nozoom -noflip -nounicode \ + -noutf8' -- $cur ) ) + # add mplayer specific options + [[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( "${COMPREPLY[@]}" \ + $(compgen -W '-autoq -autosync -benchmark \ + -framedrop -h -help -hardframedrop \ + -identify -input -lircconf -loop \ + -nojoystick -nolirc -nortc -playlist \ + -quiet -really-quiet -rnd -sdp -skin \ + -slave -softsleep -speed -sstep \ + -use-stdin -dumpaudio -dumpfile \ + -dumpstream -dumpvideo -dumpmicrodvdsub\ + -dumpmpsub -dumpsrtsub -dumpjacosub \ + -dumpsami -dumpsub -osdlevel -af \ + -af-adv -ao -aofile -aop -delay -mixer \ + -nowaveheader -bpp -brightness \ + -contrast -display -double -dr -dxr2 \ + -fb -fbmode -fbmodeconfig -forcexv -fs \ + -geometry -hue -icelayer -jpeg \ + -monitor-dotclock -monitor-hfreq \ + -monitor-vfreq -monitoraspect \ + -nograbpointer -noslices -panscan \ + -rootwin -saturation -screenw -screenh \ + -stop-xscreensaver -vm -vo -vsync -wid \ + -xineramascreen -z -zrbw -zrcrop \ + -zrdev -zrfd -zrhelp -zrnorm -zrquality \ + -zrvdec -zrhdec -zrxdoff -zrydoff -y \ + -edl -edlout -enqueue -fixed-vo \ + -menu -menu-root -menu-cfg -shuffle \ + -format -aahelp -dfbopts -fstype \ + -guiwid -nokeepaspect -x --help \ + -aaosdcolor -aasubcolor -aadriver \ + -aaextended -aaeight' -- $cur) ) + # add mencoder specific options + [[ "$cmd" = mencoder ]] && COMPREPLY=( "${COMPREPLY[@]}" \ + $(compgen -W '-audio-density -audio-delay \ + -audio-preload -divx4opts -endpos \ + -ffourcc -include -info -lameopts \ + -lavcopts -noskip -o -oac -ofps -ovc \ + -passlogfile -skiplimit -vobsubout \ + -vobsuboutindex -vobsuboutid \ + -xvidencopts -of --verbose' -- $cur) ) + ;; + *) + _filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fli|FLI|flv|FLV|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[34]|MP[34]|m4v|M4V|og[gm]|OG[GM]|wav|WAV|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3gp|mpc|MPC|flac|FLAC|flv|FLV|divx|DIVX)' + ;; + esac + + return 0 +} +complete $filenames -F _mplayer mplayer mencoder gmplayer kplayer +} + +# KDE dcop completion +# +have dcop && +_dcop() +{ + local cur compstr + + COMPREPLY=() + cur=`_get_cword` + if [ -z $cur ]; then + compstr=${COMP_WORDS[*]} + else + compstr=$( command echo ${COMP_WORDS[*]} | sed "s/ $cur$//" ) + fi + COMPREPLY=( $( compgen -W '$( command $compstr | sed s/\(.*\)// )' -- $cur ) ) +} && +complete -F _dcop dcop + +# wvdial(1) completion +# +have wvdial && +_wvdial() +{ + local cur prev config i IFS=$'\t\n' + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + --config) + _filedir + return 0 + ;; + esac + + case $cur in + -*) + COMPREPLY=( $( compgen -W '--config --chat \ + --remotename --help --version --no-syslog' \ + -- $cur ) ) + ;; + *) + # start with global and personal config files + config="/etc/wvdial.conf"$'\t'"$HOME/.wvdialrc" + # replace with command line config file if present + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == "--config" ]]; then + config=${COMP_WORDS[i+1]} + break + fi + done + # parse config files for sections and + # remove default section + COMPREPLY=( $( sed -ne \ + "s|^\[Dialer \($cur.*\)\]$|\1|p" \ + $config 2>/dev/null |grep -v '^Defaults$')) + # escape spaces + COMPREPLY=${COMPREPLY// /\\ } + ;; + esac + +} && +complete -F _wvdial wvdial + +# gpg(1) completion +# +have gpg && +_gpg() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(s|-sign|-clearsign|-decrypt-files|-load-extension)) + _filedir + return 0 + ;; + --@(export|@(?(l|nr|nrl)sign|edit)-key)) + # return list of public keys + COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*/\([^ ]*\).*\(<\([^>]*\)>\).*$@\1 \3@p')" -- "$cur" )) + return 0 + ;; + -@(r|-recipient)) + COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1@p')" -- "$cur" )) + if [ -e ~/.gnupg/gpg.conf ]; then + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf )" -- "$cur") ) + fi + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-s -b -e -f -c -d -a -r -u -Z -o -v\ + -q -n -N $(gpg --dump-options)' -- $cur ) ) + fi + +} && +complete -F _gpg $default gpg + +# iconv(1) completion +# +have iconv && +_iconv() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(f|t|-@(from|to)-code)) + COMPREPLY=( $( compgen -W \ + '$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) ) + return 0 + ;; + esac + + + if [[ "$cur" = -* ]]; then + COMPREPLY=( $( compgen -W '--from-code -f --to-code -t --list + --output -o --verbose' -- "$cur" ) ) + return 0 + fi +} && +complete -F _iconv $default iconv + +# dict(1) completion +# +{ have dict || have rdict; } && { +_dictdata() +{ + dict $host $port $1 2>/dev/null | sed -ne \ + 's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p' +} + +_dict() +{ + local cur prev host port db dictfile + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + dictfile=/usr/share/dict/words + + for (( i=1; i < COMP_CWORD; i++ )); do + case "${COMP_WORDS[i]}" in + -@(h|--host)) + host=${COMP_WORDS[i+1]} + [ -n "$host" ] && host="-h $host" + i=$((++i)) + ;; + -@(p|-port)) + port=${COMP_WORDS[i+1]} + [ -n "$port" ] && port="-p $port" + i=$((++i)) + ;; + -@(d|-database)) + db=${COMP_WORDS[i+1]} + [ -n "$db" ] && host="-d $db" + i=$((++i)) + ;; + *) + ;; + esac + done + + if [[ "$cur" = -* ]]; then + COMPREPLY=( $( compgen -W '-h --host -p --port -d --database \ + -m --match -s --strategy -c --config -C \ + --nocorrect -D --dbs -S --strats -H \ + --serverhelp -i --info -I --serverinfo \ + -a --noauth -u --user -k --key -V --version \ + -L --license --help -v --verbose -r --raw \ + -P --pager --debug --html --pipesize --client' \ + -- "$cur" ) ) + return 0 + fi + + case "$prev" in + -@(d|-database|i|info)) + COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) ) + return 0 + ;; + -@(s|-strategy)) + COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) ) + return 0 + ;; + *) + ;; + esac + + [ -r $dictfile ] && \ + COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) ) +} +complete -F _dict $default dict rdict +} + +# cdrecord(1) completion +# +have cdrecord && +_cdrecord() +{ + local cur prev i generic_options track_options track_mode + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + # foo=bar style option + if [[ "$cur" == *=* ]]; then + prev=${cur/=*/} + cur=${cur/*=/} + case "$prev" in + @(text|cue)file) + _filedir + return 0 + ;; + blank) + COMPREPLY=( $( compgen -W 'help all fast \ + track unreserve trtail unclose session' \ + -- $cur ) ) + return 0 + ;; + driveropts) + COMPREPLY=( $( compgen -W 'burnfree noburnfree\ + varirec= audiomaster forcespeed noforcespeed\ + speedread nospeedread singlesession \ + nosinglesession hidecdr nohidecdr tattooinfo\ + tattoofile=' -- $cur ) ) + return 0 + ;; + esac + fi + + generic_options=(-version -v -V -d -silent -s -force -immed -dummy \ + -dao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc \ + -atip -fix -nofix -waiti -load -lock -eject -format \ + -setdropts -checkdrive -prcap -inq -scanbus -reset \ + -abort -overburn -ignsize -useinfo -packet -noclose \ + -text debug= kdebug= kd= minbuf= speed= blank= fs= \ + dev= gracetime= timeout= driver= driveropts= \ + defpregap= pktsize= mcn= textfile= cuefile=) + track_options=(-audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \ + -isosize -pad padsize= -nopad -shorttrack -noshorttrack\ + pregap= -preemp -nopreemp -copy -nocopy -scms tcsize= \ + isrc= index=) + # look if previous was either a file or a track option + track_mode=0 + if [ $COMP_CWORD -gt 1 ]; then + if [ -f "$prev" ]; then + track_mode=1 + else + for (( i=0; i < ${#track_options[@]}; i++ )); do + if [[ "${track_options[i]}" == "$prev" ]]; then + track_mode=1 + break + fi + done + fi + fi + + # files are always eligible completion + _filedir + # track options are always available + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '${track_options[@]}' -- $cur ) ) + # general options are no more available after file or track option + if [ $track_mode -eq 0 ]; then + COMPREPLY=( "${COMPREPLY[@]}" \ + $( compgen -W '${generic_options[@]}' -- $cur ) ) + fi + +} && +complete -F _cdrecord $filenames cdrecord + +# mkisofs(8) completion +# +have mkisofs && +_mkisofs() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(o|abstract|biblio|check-session|copyright|log-file|root-info|prep-boot|*-list)) + _filedir + return 0 + ;; + -*-charset) + COMPREPLY=( $( mkisofs -input-charset help 2>&1 | \ + tail +3 | grep "^$cur") ) + return 0 + ;; + -uid) + _uids + return 0 + ;; + -gid) + _gids + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-abstract -A -allow-lowercase \ + -allow-multidot -biblio -cache-inodes \ + -no-cache-inodes -b -eltorito-alt-boot -B -G \ + -hard-disk-boot -no-emul-boot -no-boot \ + -boot-load-seg -boot-load-size \ + -boot-info-table -C -c -check-oldname \ + -check-session -copyright -d -D -dir-mode \ + -dvd-video -f -file-mode -gid -gui \ + -graft-points -hide -hide-list -hidden \ + -hidden-list -hide-joliet -hide-joliet-list \ + -hide-joliet-trans-tbl -hide-rr-moved \ + -input-charset -output-charset -iso-level -J \ + -joliet-long -jcharset -l -L -log-file -m \ + -exclude-list -max-iso9660-filenames -M -N \ + -new-dir-mode -nobak -no-bak -force-rr -no-rr \ + -no-split-symlink-components \ + -no-split-symlink-fields -o -pad -no-pad \ + -path-list -P -p -print-size -quiet -R -r \ + -relaxed-filenames -sort -split-output \ + -stream-media-size -stream-file-name -sysid -T\ + -table-name -ucs-level -udf -uid \ + -use-fileversion -U -no-iso-translate -V \ + -volset -volset-size -volset-seqno -v -x -z \ + -hfs -apple -map -magic -hfs-creator \ + -hfs-type -probe -no-desktop -mac-name \ + -boot-hfs-file -part -auto -cluster-size \ + -hide-hfs -hide-hfs-list -hfs-volid \ + -icon-position -root-info -prep-boot \ + -input-hfs-charset -output-hfs-charset \ + -hfs-unlock -hfs-bless -hfs-parms --cap \ + --netatalk --double --ethershare --ushare \ + --exchange --sgi --xinet --macbin --single \ + --dave --sfm --osx-double --osx-hfs' -- $cur )) + else + _filedir + fi + +} && +complete -F _mkisofs $filenames mkisofs + +# mc(1) completion +# +have mc && +_mc() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + # -name value style option + case "$prev" in + -@(e|v|l|P)) + _filedir + return 0 + ;; + esac + + # --name=value style option + if [[ "$cur" == *=* ]]; then + prev=${cur/=*/} + cur=${cur/*=/} + case "$prev" in + --@(edit|view|ftplog|printwd)) + _filedir + return 0 + ;; + esac + fi + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-a --stickchars -b --nocolor -c \ + --color -C --colors= -d --nomouse -e --edit= -f \ + --datadir -k --resetsoft -l --ftplog= -P --printwd= \ + -s --slow -t --termcap -u --nosubshell -U --subshell \ + -v --view= -V --version -x --xterm -h --help' -- $cur ) ) + else + _filedir -d + fi +} && +complete -F _mc $filenames mc + +# yum(8) completion +# +have yum && { +_yum() +{ + local cur prev special + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist) ]]; then + special=${COMP_WORDS[i]} + fi + done + + if [ -n "$special" ]; then + case $special in + install|deplist) + COMPREPLY=( $( compgen -W '$( yum -C list | cut -d" " -f1 )' -- $cur ) ) + return 0 + ;; + *) + _rpm_installed_packages + return 0 + ;; + esac + fi + + case $cur in + --*) + COMPREPLY=( $( compgen -W '--installroot --version --help --enablerepo --disablerepo --exclude --obsoletes --noplugins' -- $cur ) ) + return 0 + ;; + -*) + COMPREPLY=( $( compgen -W '-c -e -d -y -t -R -C -h' -- $cur ) ) + return 0 + ;; + esac + + case $prev in + list) + COMPREPLY=( $( compgen -W 'all available updates installed extras obsoletes recent' -- $cur ) ) + ;; + clean) + COMPREPLY=( $( compgen -W 'packages headers metadata cache dbcache all' -- $cur ) ) + ;; + localinstall) + _filedir rpm + ;; + -c) + _filedir + ;; + --installroot) + _filedir -d + ;; + *) + COMPREPLY=( $( compgen -W 'install update check-update upgrade remove list \ + search info provides clean groupinstall groupupdate \ + grouplist deplist erase groupinfo groupremove \ + localinstall localupdate makecache resolvedep \ + shell whatprovides' -- $cur ) ) + ;; + esac +} +complete -F _yum $filenames yum + +# yum-arch(8) completion +# +_yum_arch() +{ + local cur + COMPREPLY=() + cur=`_get_cword` + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- $cur ) ) + ;; + *) + _filedir -d + ;; + esac + + return 0 + +} +complete -F _yum_arch $filenames yum-arch +} + +# ImageMagick completion +# +have convert && { +_ImageMagick() +{ + local prev + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -channel) + COMPREPLY=( $( compgen -W 'Red Green Blue Opacity \ + Matte Cyan Magenta Yellow Black' -- $cur ) ) + return 0 + ;; + -colormap) + COMPREPLY=( $( compgen -W 'shared private' -- $cur ) ) + return 0 + ;; + -colorspace) + COMPREPLY=( $( compgen -W 'GRAY OHTA RGB Transparent \ + XYZ YCbCr YIQ YPbPr YUV CMYK' -- $cur ) ) + return 0 + ;; + -compose) + COMPREPLY=( $( compgen -W 'Over In Out Atop Xor Plus \ + Minus Add Subtract Difference Multiply Bumpmap\ + Copy CopyRed CopyGreen CopyBlue CopyOpacity' \ + -- $cur ) ) + return 0 + ;; + -compress) + COMPREPLY=( $( compgen -W 'None BZip Fax Group4 JPEG \ + Lossless LZW RLE Zip' -- $cur ) ) + return 0 + ;; + -dispose) + COMPREPLY=( $( compgen -W 'Undefined None Background \ + Previous' -- $cur ) ) + return 0 + ;; + -encoding) + COMPREPLY=( $( compgen -W 'AdobeCustom AdobeExpert \ + AdobeStandard AppleRoman BIG5 GB2312 Latin2 \ + None SJIScode Symbol Unicode Wansung' -- $cur)) + return 0 + ;; + -endian) + COMPREPLY=( $( compgen -W 'MSB LSB' -- $cur ) ) + return 0 + ;; + -filter) + COMPREPLY=( $( compgen -W 'Point Box Triangle Hermite \ + Hanning Hamming Blackman Gaussian Quadratic \ + Cubic Catrom Mitchell Lanczos Bessel Sinc' \ + -- $cur ) ) + return 0 + ;; + -format) + COMPREPLY=( $( convert -list format | \ + awk '/ [r-][w-][+-] / {print $1}' | \ + tr -d '*' | tr [:upper:] [:lower:] | \ + grep "^$cur" ) ) + return 0 + ;; + -gravity) + COMPREPLY=( $( compgen -W 'Northwest North NorthEast \ + West Center East SouthWest South SouthEast' \ + -- $cur ) ) + return 0 + ;; + -intent) + COMPREPLY=( $( compgen -W 'Absolute Perceptual \ + Relative Saturation' -- $cur ) ) + return 0 + ;; + -interlace) + COMPREPLY=( $( compgen -W 'None Line Plane Partition' \ + -- $cur ) ) + return 0 + ;; + -limit) + COMPREPLY=( $( compgen -W 'Disk File Map Memory' \ + -- $cur ) ) + return 0 + ;; + -list) + COMPREPLY=( $( compgen -W 'Delegate Format Magic \ + Module Resource Type' -- $cur ) ) + return 0 + ;; + -map) + COMPREPLY=( $( compgen -W 'best default gray red \ + green blue' -- $cur ) ) + _filedir + return 0 + ;; + -noise) + COMPREPLY=( $( compgen -W 'Uniform Gaussian \ + Multiplicative \ + Impulse Laplacian Poisson' -- $cur ) ) + return 0 + ;; + -preview) + COMPREPLY=( $( compgen -W 'Rotate Shear Roll Hue \ + Saturation Brightness Gamma Spiff \ + Dull Grayscale Quantize Despeckle \ + ReduceNoise AddNoise Sharpen Blur \ + Treshold EdgeDetect Spread Shade \ + Raise Segment Solarize Swirl Implode \ + Wave OilPaint CharcoalDrawing JPEG' \ + -- $cur ) ) + return 0 + ;; + -@(mask|profile|texture|tile|write)) + _filedir + return 0 + ;; + -type) + COMPREPLY=( $( compgen -W 'Bilevel Grayscale Palette \ + PaletteMatte TrueColor TrueColorMatte \ + ColorSeparation ColorSeparationlMatte \ + Optimize' -- $cur ) ) + return 0 + ;; + -units) + COMPREPLY=( $( compgen -W 'Undefined PixelsPerInch \ + PixelsPerCentimeter' -- $cur ) ) + return 0 + ;; + -virtual-pixel) + COMPREPLY=( $( compgen -W 'Constant Edge mirror tile' \ + -- $cur ) ) + return 0 + ;; + -visual) + COMPREPLY=( $( compgen -W 'StaticGray GrayScale \ + StaticColor PseudoColor TrueColor \ + DirectColor defaut visualid' -- $cur )) + return 0 + ;; + esac +} + +_convert() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + _ImageMagick + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-adjoin -affine -antialias -append \ + -authenticate -average -background -black-threshold \ + -blue-primary -blur -border -bordercolor -channel \ + -charcoal -chop -clip -coalesce -colorize -colors \ + -colorspace -comment -compress -contrast -convolve \ + -crop -cycle -debug -deconstruct -delay -density \ + -depth -despeckle -display -dispose -dither -draw \ + -edge -emboss -encoding -endian -enhance -equalize \ + -extract -fill -filter -flatten -flip -flop -font \ + -frame -fuzz -gamma -gaussian -geometry \ + -green-primary -gravity -help -implode -intent \ + -interlace -label -lat -level -limit -list -log -loop \ + -map -mask -matte -median -modulate -monochrome \ + -morph -mosaic -negate -noop -noise -normalize \ + -opaque -ordered-dither -page -paint -ping -pointsize \ + -preview -profile -quality -raise -random-threshold \ + -region -raise -red-primary -render -resize -resample \ + -roll -rotate -sample -sampling-factor -scale -scene \ + -seed -segment -shade -sharpen -shave -shear -size \ + -solarize -spread -stroke -strokewidth -swirl \ + -texture -threshold -thumbnail -tile -transform \ + -transparent -treedepth -trim -type -undercolor \ + -units -unsharp -verbose -version -view \ + -virtual-pixel -wave -white-point -white-threshold \ + -write' -- $cur ) ) + elif [[ "$cur" == +* ]]; then + COMPREPLY=( $( compgen -W '+adjoin +append +compress \ + +contrast +debug +dither +endian +gamma +label +map \ + +mask +matte +negate +noise +page +raise +render \ + +write' -- $cur ) ) + else + _filedir + fi +} +complete -F _convert $filenames convert + +_mogrify() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + _ImageMagick + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-affine -antialias -authenticate \ + -background -black-threshold -blue-primary -blur \ + -border -bordercolor -channel -charcoal -chop \ + -colorize -colors -colorspace -comment -compress \ + -contrast -convolve -crop -cycle -debug -delay \ + -density -depth -despeckle -display -dispose -dither \ + -draw -edge -emboss -encoding -endian -enhance \ + -equalize -extract -fill -filter -flip -flop -font \ + -format -frame -fuzz -gamma -gaussian -geometry \ + -green-primary -implode -interlace -help -label -lat \ + -level -limit -list -log -loop -map -mask -matte \ + -median -modulate -monochrome -negate -noop \ + -normalize -opaque -page -paint -fill -ordered-dither \ + -pointsize -profile -quality -raise -random-threshold \ + -red-primary -region -resample -resize -roll -rotate \ + -sample -sampling-factor -scale -scene -seed -segment \ + -shade -sharpen -shear -size -solarize -spread \ + -stroke -strokewidth -swirl -texture -threshold \ + -thumbnail -tile -transform -transparent -treedepth \ + -trim -type -undercolor -units -unsharp -verbose \ + -version -view -virtual-pixel -wave -white-point \ + -white-threshold' -- $cur ) ) + elif [[ "$cur" == +* ]]; then + COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \ + +endian +gamma +label +map +mask +matte +negate +page \ + +raise' -- $cur ) ) + else + _filedir + fi +} +complete -F _mogrify $filenames mogrify + +_display() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + _ImageMagick + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-authenticate -backdrop -border \ + -colormap -colors -colorspace -comment -compress \ + -contrast -crop -debug -delay -density -depth \ + -despeckle -display -dispose -dither -edge -endian \ + -enhance -extract -filter -flip -flop -frame -gamma \ + -geometry -help -immutable -interlace -label -limit \ + -log -map -matte -monochrome -negate -noop -page \ + -quality -raise -remote -roll -rotate -sample \ + -sampling-factor -scene -segment -sharpen -size \ + -texture -treedepth -trim -update -verbose -version \ + -virtual-pixel -window -window_group -write' -- $cur)) + elif [[ "$cur" == +* ]]; then + COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \ + +endian +gamma +label +map +matte +negate +page \ + +raise +write' -- $cur ) ) + else + _filedir + fi +} +complete -F _display $filenames display + +_animate() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + _ImageMagick + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-authenticate -backdrop -colormap \ + -colors -colorspace -crop -debug -delay -density \ + -depth -display -dither -extract -gamma -geometry \ + -help -interlace -limit -log -matte -map -monochrome \ + -noop -pause -remote -rotate -sampling-factor -scene \ + -size -treedepth -trim -verbose -version -visual \ + -virtual-pixel -window' -- $cur ) ) + elif [[ "$cur" == +* ]]; then + COMPREPLY=( $( compgen -W '+debug +dither +gamma +map +matte' -- $cur ) ) + else + _filedir + fi +} +complete -F _animate $filenames animate + +_identify() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + _ImageMagick + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-authenticate -debug -density \ + -depth -extract -format -help -interlace -limit -list \ + -log -size -sampling-factor -verbose -version \ + -virtual-pixel' -- $cur ) ) + elif [[ "$cur" == +* ]]; then + COMPREPLY=( $( compgen -W '+debug ' -- $cur ) ) + else + _filedir + fi +} +complete -F _identify $filenames identify + +_montage() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + _ImageMagick + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-adjoin -affine -authenticate \ + -blue-primary -blur -colors -colorspace -comment \ + -compose -compress -crop -debug -density -depth \ + -display -dispose -dither -draw -encoding -endian \ + -extract -fill -filter -flip -flop -frame -gamma \ + -geometry -gravity -green-primary -interlace -help \ + -label -limit -log -matte -mode -monochrome -noop \ + -page -pointsize -quality -red-primary -resize \ + -rotate -sampling-factor -scene -shadow -size \ + -stroke -texture -thumbnail -tile -transform \ + -transparent -treedepth -trim -type -verbose \ + -version -virtual-pixel -white-point' -- $cur ) ) + elif [[ "$cur" == +* ]]; then + COMPREPLY=( $( compgen -W '+adjoin +compress +debug +dither \ + +endian +gamma +label +matte +page' -- $cur ) ) + else + _filedir + fi +} +complete -F _montage $filenames montage + +_composite() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + _ImageMagick + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-affine -authenticate \ + -blue-primary -colors -colorspace -comment -compose \ + -compress -debug -density -depth -displace -display \ + -dispose -dissolve -dither -encoding -endian -extract \ + -filter -font -geometry -gravity -green-primary -help \ + -interlace -label -limit -log -matte -monochrome \ + -negate -page -profile -quality -red-primary -rotate \ + -resize -sampling-factor -scene -sharpen -size \ + -stegano -stereo -thumbnail -tile -transform \ + -treedepth -type -units -unsharp -verbose -version \ + -virtual-pixel -watermark -white-point -write' \ + -- $cur ) ) + elif [[ "$cur" == +* ]]; then + COMPREPLY=( $( compgen -W '+compress +debug +dither +endian +label \ + +matte +negate +page +write' -- $cur ) ) + else + _filedir + fi +} +complete -F _composite $filenames composite +} + +# dd(1) completion +# +have dd && +_dd() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + case "$cur" in + if=*|of=*) + cur=${cur#*=} + _filedir + return 0 + ;; + conv=*) + cur=${cur#*=} + COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock \ + lcase notrunc ucase swab noerror sync' \ + -- $cur ) ) + return 0 + ;; + esac + + _expand || return 0 + + COMPREPLY=( $( compgen -W '--help --version' -- $cur ) \ + $( compgen -W 'bs cbs conv count ibs if obs of seek skip'\ + -S '=' -- $cur ) ) +} && +complete -F _dd $nospace $filenames dd + +# CUPS cancel(1) completion +# +have cancel && +_cancel() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + COMPREPLY=( $( lpstat | cut -d' ' -f1 | grep "^$cur" ) ) +} && +complete -F _cancel $filenames cancel + +# aspell(1) completion +# +have aspell && { +_aspell_dictionary() +{ + local datadir + datadir=/usr/lib/aspell + COMPREPLY=( $( command ls $datadir/*.@(multi|alias) ) ) + COMPREPLY=( ${COMPREPLY[@]%.@(multi|alias)} ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$datadir/}' -- $cur ) ) +} + +_aspell() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + # --name value style option + case "$prev" in + @(-c|-p|check)) + _filedir + return 0 + ;; + @(dump|create|merge)) + COMPREPLY=( $( compgen -W 'master personal repl' -- $cur ) ) + return 0 + ;; + -d) + _aspell_dictionary + return 0 + ;; + esac + + # --name=value style option + if [[ "$cur" == *=* ]]; then + prev=${cur/=*/} + cur=${cur/*=/} + case "$prev" in + --@(conf|personal|repl|per-conf)) + _filedir + return 0 + ;; + --@(conf-dir|data-dir|dict-dir|home-dir|local-data-dir|prefix)) + _filedir -d + return 0 + ;; + --master) + _aspell_dictionary + return 0 + ;; + --mode) + COMPREPLY=( $( compgen -W 'none url email sgml tex' -- $cur ) ) + return 0 + ;; + --sug-mode) + COMPREPLY=( $( compgen -W 'ultra fast normal bad-speller' -- $cur ) ) + return 0 + ;; + --keymapping) + COMPREPLY=( $( compgen -W 'aspell ispell' -- $cur ) ) + return 0 + ;; + esac + fi + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= \ + --encoding= --add-filter= --rem-filter= --mode= -e \ + -H -t --add-extra-dicts= --rem-extra-dicts= \ + --home-dir= -W --ignore= --ignore-accents \ + --dont-ignore-accents --ignore-case --dont-ignore-case \ + --ignore-repl --dont-ignore-repl --jargon= --keyboard= \ + --lang= --language-tag= --local-data-dir= -d --master= \ + --module= --add-module-search-order= \ + --rem-module-search-order= --per-conf= -p --personal= \ + --prefix= --repl= -C -B --run-together --dont-run-together \ + --run-together-limit= --run-together-min= --save-repl \ + --dont-save-repl --set-prefix --dont-set-prefix --size= \ + --spelling= --strip-accents --dont-strip-accents \ + --sug-mode= --add-word-list-path= --rem-word-list-path= \ + -b -x --backup -b|-x --dont-backup --reverse --dont-reverse \ + --time --dont-time --keymapping= --add-email-quote= \ + --rem-email-quote= --email-margin= --add-tex-command= \ + --rem-tex-command= --tex-check-comments \ + --dont-tex-check-comments --add-tex-extension= \ + --rem-tex-extension= --add-sgml-check= --rem-sgml-check= \ + --add-sgml-extension= --rem-sgml-extension=' -- $cur ) ) + else + COMPREPLY=( $( compgen -W '-? help -c check -a pipe -l list \ + config config soundslike filter -v version dump \ + create merge' -- $cur ) ) + fi + +} +complete -F _aspell $filenames aspell +} + +# xmms(1) completion +# +have xmms && +_xmms() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-h --help -r --rew -p --play \ + -u --pause -s --stop -t --play-pause -f --fwd -e \ + --enqueue -m --show-main-window -i --sm-client-id \ + -v --version' -- $cur ) ) + else + _filedir '@(mp[23]|MP[23]|ogg|OGG|wav|WAV|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)' + + fi + +} && +complete -F _xmms $filenames xmms + +# info(1) completion +# +have info && +_info() +{ + local cur infopath UNAME + + COMPREPLY=() + cur=`_get_cword` + + _expand || return 0 + + # default completion if parameter contains / + if [[ "$cur" == */* ]]; then + _filedir + return 0 + fi + + infopath='/usr/share/info' + + if [ "${INFOPATH: -1:1}" == ':' ]; then + infopath=${INFOPATH}${infopath} + elif [ ${INFOPATH:+set} ]; then + infopath=$INFOPATH + fi + + infopath=$infopath: + if [ -n "$cur" ]; then + infopath="${infopath//://$cur* }" + else + infopath="${infopath//:// }" + fi + + # redirect stderr for when path doesn't exist + COMPREPLY=( $( eval command ls "$infopath" 2>/dev/null ) ) + # weed out directory path names and paths to info pages + COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) + # weed out info dir file + for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do + if [ "${COMPREPLY[$i]}" == 'dir' ]; then + unset COMPREPLY[$i]; + fi; + done + # strip suffix from info pages + COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) ) + + return 0 +} && +complete -F _info $filenames info + +# dhclient(1) completion +# +have dhclient && _dhclient() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(cf|lf|pf|sf)) + _filedir + return 0 + ;; + -s) + _known_hosts + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-p -d -q -1 -r -lf -pf \ + -cf -sf -s -g -n -nw -w' -- $cur ) ) + else + _available_interfaces + fi +} && +complete -F _dhclient dhclient + +# lvm(8) completion +# +have lvm && { +_volumegroups() +{ + COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \ + sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- $cur ) ) +} + +_physicalvolumes() +{ + COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \ + sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- $cur ) ) +} + +_logicalvolumes() +{ + COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \ + sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- $cur ) ) +} + +_units() +{ + COMPREPLY=( $( compgen -W 'h s b k m g t H K M G T' -- $cur ) ) +} + +_sizes() +{ + COMPREPLY=( $( compgen -W 'k K m M g G t T' -- $cur ) ) +} + +_args() +{ + args=0 + if [[ "${COMP_WORDS[0]}" == lvm ]]; then + offset=2 + else + offset=1 + fi + for (( i=$offset; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" != -* ]]; then + args=$(($args + 1)) + fi + done +} + +_lvmdiskscan() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -h -? --help -l \ + --lvmpartition -v --verbose --version' -- $cur ) ) + fi +} +complete -F _lvmdiskscan lvmdiskscan + +_pvscan() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -e \ + --exported -n --novolumegroup -h -? \ + --help --ignorelockingfailure -P \ + --partial -s --short -u --uuid -v \ + --verbose --version' -- $cur ) ) + fi +} +complete -F _pvscan pvscan + +_pvs() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(o|O|-options|-sort)) + COMPREPLY=( $( compgen -W 'pv_fmt pv_uuid \ + pv_size pv_free pv_used pv_name \ + pv_attr pv_pe_count \ + pv_pe_alloc_count' -- $cur ) ) + return 0 + ;; + --units) + _units + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--aligned -a --all -d --debug \ + -h -? --help --ignorelockingfailure --noheadings \ + --nosuffix -o --options -O --sort \ + --separator --unbuffered --units \ + -v --verbose --version' -- $cur ) ) + else + _physicalvolumes + fi +} +complete -F _pvs pvs + +_pvdisplay() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + --units) + _units + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \ + -v --verbose -d --debug -h --help --version' -- $cur ) ) + else + _physicalvolumes + fi +} +complete -F _pvdisplay pvdisplay + +_pvchange() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|x|-autobackup|--allocatable)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-a --all -A --autobackup \ + -d --debug -h --help -t --test -u --uuid -x \ + --allocatable -v --verbose --addtag --deltag \ + --version' -- $cur ) ) + else + _physicalvolumes + fi +} +complete -F _pvchange pvchange + +_pvcreate() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + --restorefile) + _filedir + return 0 + ;; + -@(M|-metadatatype)) + COMPREPLY=( $( compgen -W '1 2' -- $cur ) ) + return 0 + ;; + --metadatacopies) + COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) ) + return 0 + ;; + --@(metadatasize|setphysicalvolumesize)) + _sizes + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--restorefile -d --debug -f \ + --force -h -? --help --labelsector -M --metadatatype \ + --metadatacopies --metadatasize \ + --setphysicalvolumesize -t --test -u --uuid uuid -v \ + --verbose -y --yes --version' -- $cur ) ) + else + _physicalvolumes + fi +} +complete -F _pvcreate pvcreate + +_pvmove() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + -@(n|-name)) + _logicalvolumes + return 0 + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--abort -A --autobackup \ + -b --background -d --debug -f --force -h -? \ + --help -i --interval -t --test -v --verbose \ + --version -n --name' -- $cur ) ) + else + _physicalvolumes + fi +} +complete -F _pvmove pvmove + +_pvremove() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -f --force -h -? \ + --help -y --yes -t --test -v --verbose \ + --version' -- $cur ) ) + else + _physicalvolumes + fi +} +complete -F _pvremove pvremove + +_vgscan() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -h --help \ + --ignorelockingfailure --mknodes -P \ + --partial -v --verbose --version' -- $cur ) ) + fi +} +complete -F _vgscan vgscan + +_vgs() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(o|O|-options|-sort)) + COMPREPLY=( $( compgen -W 'vg_fmt vg_uuid vg_name \ + vg_attr vg_size vg_free vg_sysid \ + vg_extent_size vg_extent_count vg_free_count \ + max_lv max_pv pv_count lv_count snap_count \ + vg_seqno' -- $cur ) ) + return 0 + ;; + --units) + _units + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--aligned -d --debug \ + -h --help --ignorelockingfailure --noheadings \ + --nosuffix -o --options -O --sort -P --partial \ + --separator --unbuffered --units \ + -v --verbose --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgs vgs + +_vgdisplay() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + --units) + _units + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \ + -P --partial -A --activevolumegroups -v --verbose \ + -d --debug -h --help --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgdisplay vgdisplay + +_vgchange() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(a|A|x|-available|-autobackup|-resizeable)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup --alloc -P \ + --partial -d --debug -h --help --ignorelockingfailure \ + -t --test -u --uuid -v --verbose --version -a \ + --available -x --resizeable -l --logicalvolume \ + --addtag --deltag' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgchange vgchange + +_vgcreate() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + -@(M|-metadatatype)) + COMPREPLY=( $( compgen -W '1 2' -- $cur ) ) + return 0 + ;; + -@(s|-physicalextentsize)) + _sizes + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup --addtag \ + --alloc -d --debug -h --help -l --maxlogicalvolumes \ + -M --metadatatype -p --maxphysicalvolumes -s \ + --physicalextentsize -t --test -v --verbose \ + --version' -- $cur ) ) + else + _args + if [ $args -eq 0 ]; then + _volumegroups + else + _physicalvolumes + fi + fi +} +complete -F _vgcreate vgcreate + +_vgremove() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -h --help -t --test \ + -v --verbose --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgremove vgremove + +_vgrename() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \ + -? --help -t --test -v --verbose --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgrename vgrename + +_vgreduce() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-a --all -A --autobackup -d \ + --debug -h --help --removemissing -t --test -v \ + --verbose --version' -- $cur ) ) + + else + _args + if [ $args -eq 0 ]; then + _volumegroups + else + _physicalvolumes + fi + fi +} +complete -F _vgreduce vgreduce + +_vgextend() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + -@(L|-size)) + _sizes + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \ + -? --help -t --test -v --verbose --version' -- $cur ) ) + else + _args + if [ $args -eq 0 ]; then + _volumegroups + else + _physicalvolumes + fi + fi +} +complete -F _vgextend vgextend + +_vgport() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-a --all -d --debug -h \ + -? --help -v --verbose --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgport vgimport vgexport + +_vgck() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -h \ + -? --help -v --verbose --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgck vgck + +_vgconvert() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(M|-metadatatype)) + COMPREPLY=( $( compgen -W '1 2' -- $cur ) ) + return 0 + ;; + --metadatacopies) + COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) ) + return 0 + ;; + --metadatasize) + _sizes + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -h --help --labelsector \ + -M --metadatatype --metadatacopies --metadatasize \ + -t --test -v --verbose --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgconvert vgconvert + +_vgcfgbackup() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(f|-file)) + _filedir + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -f --file -h --help \ + --ignorelockingfailure -P --partial -v --verbose \ + --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgcfgbackup vgcfgbackup + +_vgcfgrestore() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(f|-file)) + _filedir + return 0 + ;; + -@(M|-metadatatype)) + COMPREPLY=( $( compgen -W '1 2' -- $cur ) ) + return 0 + ;; + -@(n|-name)) + _volumegroups + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -f --file -l --list \ + -h --help -M --Metadatatype -n --name -t --test \ + -v --verbose --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgcfgrestore vgcfgrestore + +_vgmerge() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \ + -h --help -l --list -t --test -v --verbose \ + --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgmerge vgmerge + +_vgsplit() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + -@(M|-metadatatype)) + COMPREPLY=( $( compgen -W '1 2' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \ + -h --help -l --list -M --metadatatype -t --test \ + -v --verbose --version' -- $cur ) ) + else + _args + if [ $args -eq 0 -o $args -eq 1 ]; then + _volumegroups + else + _physicalvolumes + fi + fi +} +complete -F _vgsplit vgsplit + +_vgmknodes() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-d --debug -h --help -v --verbose \ + --version' -- $cur ) ) + else + _volumegroups + fi +} +complete -F _vgmknodes vgmknodes + +_lvscan() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-b --blockdevice -d --debug \ + -h -? --help --ignorelockingfailure -P \ + --partial -v --verbose --version' -- $cur ) ) + fi +} +complete -F _lvscan lvscan + +_lvs() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(o|O|-options|-sort)) + COMPREPLY=( $( compgen -W 'lv_uuid lv_name \ + lv_attr lv_minor lv_size seg_count \ + origin snap_percent segtype stripes \ + stripesize chunksize seg_start \ + seg_size' -- $cur ) ) + return 0 + ;; + --units) + _units + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--aligned -d --debug \ + -h --help --ignorelockingfailure --noheadings \ + --nosuffix -o --options -O --sort -P --partial \ + --segments --separator --unbuffered --units \ + -v --verbose --version' -- $cur ) ) + else + _logicalvolumes + fi +} +complete -F _lvs lvs + +_lvdisplay() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + --units) + _units + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \ + -P --partial -m --maps -v --verbose -d --debug -h \ + --help --version' -- $cur ) ) + else + _logicalvolumes + fi +} +complete -F _lvdisplay lvdisplay + +_lvchange() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(a|A|C|M|-available|-autobackup|-continguous|-persistent)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + -@(p|-permission)) + COMPREPLY=( $( compgen -W 'r rw' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup -a --available \ + --addtag --alloc -C --contiguous -d --debug --deltag \ + -f --force -h --help --ignorelockingfailure -M \ + --persistent --major major --minor minor -P --partial \ + -p --permission -r --readahead --refresh -t --test \ + -v --verbose --version' -- $cur ) ) + else + _logicalvolumes + fi +} +complete -F _lvchange lvchange + +_lvcreate() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|C|M|Z|-autobackup|-continguous|-persistent|-zero)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + -@(L|-size)) + _sizes + return 0 + ;; + -@(p|-permission)) + COMPREPLY=( $( compgen -W 'r rw' -- $cur ) ) + return 0 + ;; + -@(n|-name)) + _logicalvolumes + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup --addtag --alloc \ + -C --contiguous -d --debug -h -? --help -i --stripes \ + -I --stripesize -l --extents -L --size -M --persistent \ + --major --minor -n --name -p --permission -r \ + --readahead -t --test --type -v --verbose -Z --zero \ + --version' -- $cur ) ) + else + _args + if [ $args -eq 0 ]; then + _volumegroups + else + _physicalvolumes + fi + fi +} +complete -F _lvcreate lvcreate + +_lvremove() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -f \ + --force -h -? --help -t --test -v --verbose \ + --version' -- $cur ) ) + else + _logicalvolumes + fi +} +complete -F _lvremove lvremove + +_lvrename() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \ + -? --help -t --test -v --verbose --version' -- $cur ) ) + else + _logicalvolumes + fi +} +complete -F _lvrename lvrename + +_lvreduce() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + -@(L|-size)) + _sizes + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup -d \ + --debug -f --force -h --help -l --extents \ + -L --size -n --nofsck -r --resizefs -t --test \ + -v --verbose --version' -- $cur ) ) + else + _logicalvolumes + fi +} +complete -F _lvreduce lvreduce + +_lvresize() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + -@(L|-size)) + _sizes + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup --alloc -d \ + --debug -h --help -i --stripes -I --stripesize \ + -l --extents -L --size -n --nofsck -r --resizefs \ + -t --test --type -v --verbose --version' -- $cur ) ) + else + _args + if [ $args -eq 0 ]; then + _logicalvolumes + else + _physicalvolumes + fi + fi +} +complete -F _lvresize lvresize + +_lvextend() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -@(A|-autobackup)) + COMPREPLY=( $( compgen -W 'y n' -- $cur ) ) + return 0 + ;; + -@(L|-size)) + _sizes + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-A --autobackup --alloc -d \ + --debug -h --help -i --stripes -I --stripesize \ + -l --extents -L --size -n --nofsck -r --resizefs \ + -t --test --type -v --verbose --version' -- $cur ) ) + else + _args + if [ $args -eq 0 ]; then + _logicalvolumes + else + _physicalvolumes + fi + fi +} +complete -F _lvextend lvextend + +_lvm() +{ + local prev + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W 'dumpconfig help lvchange \ + lvcreate lvdisplay lvextend lvmchange \ + lvmdiskscan lvmsadc lvmsar lvreduce \ + lvremove lvrename lvresize lvs lvscan \ + pvchange pvcreate pvdata pvdisplay pvmove \ + pvremove pvresize pvs pvscan vgcfgbackup \ + vgcfgrestore vgchange vgck vgconvert \ + vgcreate vgdisplay vgexport vgextend \ + vgimport vgmerge vgmknodes vgreduce \ + vgremove vgrename vgs vgscan vgsplit \ + version' -- $cur ) ) + else + case ${COMP_WORDS[1]} in + pvchange) + _pvchange + ;; + pvcreate) + _pvcreate + ;; + pvdisplay) + _pvdisplay + ;; + pvmove) + _pvmove + ;; + pvremove) + _pvremove + ;; + pvresize) + _pvresize + ;; + pvs) + _pvs + ;; + pvscan) + _pvscan + ;; + vgcfgbackup) + _vgcfgbackup + ;; + vgcfgrestore) + _vgcfgrestore + ;; + vgchange) + _vgchange + ;; + vgck) + _vgck + ;; + vgconvert) + _vgconvert + ;; + vgcreate) + _vgcreate + ;; + vgdisplay) + _vgdisplay + ;; + vgexport) + _vgexport + ;; + vgextend) + _vgextend + ;; + vgimport) + _vgimport + ;; + vgmerge) + _vgmerge + ;; + vgmknodes) + _vgmknodes + ;; + vgreduce) + _vgreduce + ;; + vgremove) + _vgremove + ;; + vgrename) + _vgrename + ;; + vgs) + _vgs + ;; + vgscan) + _vgscan + ;; + vgsplit) + _vgsplit + ;; + lvchange) + _lvchange + ;; + lvcreate) + _lvcreate + ;; + lvdisplay) + _lvdisplay + ;; + lvextend) + _lvextend + ;; + lvreduce) + _lvreduce + ;; + lvremove) + _lvremove + ;; + lvrename) + _lvrename + ;; + lvresize) + _lvresize + ;; + lvs) + _lvs + ;; + lvscan) + _lvscan + ;; + esac + fi +} +complete -F _lvm lvm +} + +# mkinitrd(8) completion +# +have mkinitrd && +_mkinitrd() +{ + local cur args + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + # --name value style option + case "$prev" in + --preload) + _modules + return 0 + ;; + esac + + # --name=value style option + if [[ "$cur" == *=* ]]; then + prev=${cur/=*/} + cur=${cur/*=/} + case "$prev" in + --@(with|builtin)) + _modules + return 0 + ;; + --@(fstab|dsdt)) + _filedir + return 0 + ;; + --tmpdir) + _filedir -d + return 0 + ;; + esac + fi + + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--version -v -f --preload \ + --with= --omit-scsi-modules --omit-raid-modules \ + --images-version --fstab= --nocompress --builtin= \ + --nopivot --noudev --allow-missing --tmpdir= \ + --initrdfs= --dsdt= --lvm-version= --froce-usb' \ + -- $cur ) ) + else + _count_args + + case $args in + 1) + _filedir + ;; + 2) + COMPREPLY=( $( command ls /lib/modules | grep "^$cur" ) ) + ;; + esac + fi + +} && +complete -F _mkinitrd mkinitrd + +# pkgconfig(1) completion +# +have pkg-config && +_pkg_config() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + # return list of available options + COMPREPLY=( $( compgen -W '-version --modversion \ + --atleast-pkgconfig-version= --libs --libs-only-l \ + --libs-only-other --libs-only-L --cflags \ + --cflags-only-I --cflags-only-other --variable= \ + --define-variable= --exists --uninstalled \ + --atleast-version= --exact-version= --max-version= \ + --list-all --debug --print-errors --silence-errors \ + --errors-to-stdout -? --help --usage' -- $cur)) + else + COMPREPLY=( $( pkg-config --list-all 2>/dev/null | \ + awk '{print $1}' | grep "^$cur" ) ) + fi +} && +complete -F _pkg_config pkg-config + + +# cpio(1) completion +# +have cpio && { +_cpio_format() +{ + COMPREPLY=( $( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- $cur ) ) +} + +_cpio() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + # --name value style option + case $prev in + -H) + _cpio_format + return 0 + ;; + -@(E|F|I)) + _filedir + return 0 + ;; + -R) + _usergroup + return 0 + ;; + esac + + # --name=value style option + if [[ "$cur" == *=* ]]; then + prev=${cur/=*/} + cur=${cur/*=/} + case $prev in + --format) + _cpio_format + return 0 + ;; + --@(file|pattern-file)) + _filedir + return 0 + ;; + --owner) + _usergroup + return 0 + ;; + --rsh-command) + COMPREPLY=( $( compgen -c -- $cur ) ) + return 0 + ;; + esac + fi + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through' -- $cur) ) + else + case ${COMP_WORDS[1]} in + -@(o|-create)) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-0 -a -c -v -A -B\ + -L -V -C -H -M -O -F --file= --format=\ + --message= --null --reset-access-time\ + --verbose --dot --append --block-size=\ + --dereference --io-size= --quiet\ + --force-local --rsh-command= --help\ + --version' -- $cur ) ) + fi + ;; + -@(i|-extract)) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-b -c -d -f -m -n -r\ + -t -s -u -v -B -S -V -C -E -H -M -R -I\ + -F --file= --make-directories\ + --nonmatching\ + --preserve-modification-time\ + --numeric-uid-gid --rename -t --list\ + --swap-bytes --swap --dot\ + --unconditional --verbose --block-size=\ + --swap-halfwords --io-size=\ + --pattern-file= --format= --owner=\ + --no-preserve-owner --message=\ + --force-local --no-absolute-filenames\ + --sparse --only-verify-crc --quiet\ + --rsh-command= --help\ + --version' -- $cur ) ) + fi + ;; + -@(p|-pass-through)) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-0 -a -d -l -m -u -v\ + -L -V -R --null --reset-access-time\ + --make-directories --link --quiet\ + --preserve-modification-time\ + --unconditional --verbose --dot\ + --dereference --owner=\ + --no-preserve-owner --sparse --help\ + --version' -- $cur ) ) + else + _filedir -d + fi + ;; + esac + fi +} +complete -F _cpio cpio +} + +# id(1) completion +# +have id && +_id() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\ + -r --real -u --user --help --version' -- $cur ) ) + else + COMPREPLY=( $( compgen -u $cur ) ) + fi +} && +complete -F _id id + +# getent(1) completion +# +have getent && +_getent() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + passwd) + COMPREPLY=( $( compgen -u $cur ) ) + return 0 + ;; + group) + COMPREPLY=( $( compgen -g $cur ) ) + return 0 + ;; + services) + COMPREPLY=( $( compgen -s $cur ) ) + return 0 + ;; + hosts) + COMPREPLY=( $( compgen -A hostname $cur ) ) + return 0 + ;; + protocols) + COMPREPLY=( $( getent protocols | awk '{print $1}' | grep "^$cur" ) ) + return 0 + ;; + networks) + COMPREPLY=( $( getent networks | awk '{print $1}' | grep "^$cur" ) ) + return 0 + ;; + esac + + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W 'passwd group hosts services protocols networks' -- $cur ) ) + fi +} && +complete -F _getent getent + +# ntpdate(1) completion +# +have ntpdate && +_ntpdate() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + -k) + _filedir + return 0 + ;; + -U) + COMPREPLY=( $( compgen -u $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\ + -e -k -p -o -r -t' -- $cur ) ) + else + _known_hosts + fi +} && +complete -F _ntpdate ntpdate + +# smartctl(8) completion +# +have smartctl && { +_smartctl_quietmode() +{ + COMPREPLY=( $( compgen -W 'errorsonly silent' -- $cur ) ) +} +_smartctl_device() +{ + COMPREPLY=( $( compgen -W 'ata scsi 3ware' -- $cur ) ) +} +_smartctl_tolerance() +{ + COMPREPLY=( $( compgen -W 'warn exit ignore' -- $cur ) ) +} +_smartctl_badsum() +{ + COMPREPLY=( $( compgen -W 'normal conservative permissive verypermissive' -- $cur ) ) +} +_smartctl_report() +{ + COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- $cur ) ) +} +_smartctl_feature() +{ + COMPREPLY=( $( compgen -W 'on off' -- $cur ) ) +} +_smartctl_log() +{ + COMPREPLY=( $( compgen -W 'error selftest selective directory' -- $cur ) ) +} +_smartctl_vendorattribute() +{ + COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \ + 9,temp 192,emergencyretractcyclect 193,loadunload \ + 194,10xCelsius 194,unknown 198,offlinescanuncsectorct \ + 200,writeerrorcount 201,detectedtacount 220,temp' -- $cur ) ) +} +_smartctl_firmwarebug() +{ + COMPREPLY=( $( compgen -W 'none samsung samsung2' -- $cur ) ) +} +_smartctl_presets() +{ + COMPREPLY=( $( compgen -W 'use ignore show showall' -- $cur ) ) +} +_smartctl_test() +{ + COMPREPLY=( $( compgen -W 'offline short long conveyance select afterselect,on afterselect,off pending' -- $cur ) ) +} + +_smartctl() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + # --name value style option + case "$prev" in + -q) + _smartctl_quietmode + ;; + -d) + _smartctl_device + return 0 + ;; + -t) + _smartctl_tolerance + return 0 + ;; + -b) + _smartctl_badsum + return 0 + ;; + -r) + _smartctl_report + return 0 + ;; + -s) + _smartctl_feature + return 0 + ;; + -o) + _smartctl_feature + return 0 + ;; + -S) + _smartctl_feature + return 0 + ;; + -l) + _smartctl_log + return 0 + ;; + -v) + _smartctl_vendorattribute + return 0 + ;; + -F) + _smartctl_firmwarebug + return 0 + ;; + -P) + _smartctl_presets + return 0 + ;; + -t) + _smartctl_test + return 0 + ;; + esac + + # --name=value style option + if [[ "$cur" == *=* ]]; then + prev=${cur/=*/} + cur=${cur/*=/} + case "$prev" in + --quietmode) + _smartctl_quietmode + return 0 + ;; + --device) + _smartctl_device + return 0 + ;; + --tolerance) + _smartctl_tolerance + return 0 + ;; + --badsum) + _smartctl_badsum + return 0 + ;; + --report) + _smartctl_report + return 0 + ;; + --smart) + _smartctl_feature + return 0 + ;; + --offlineauto) + _smartctl_feature + return 0 + ;; + --saveauto) + _smartctl_feature + return 0 + ;; + --log) + _smartctl_log + return 0 + ;; + --vendorattribute) + _smartctl_vendorattribute + return 0 + ;; + --firmwarebug) + _smartctl_firmwarebug + return 0 + ;; + --presets) + _smartctl_presets + return 0 + ;; + --test) + _smartctl_test + return 0 + ;; + esac + fi + + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-h --help --usage -V --version \ + --copyright --license-i --info -a --all -q \ + --quietmode= -d --device= -T --tolerance= -b --badsum= \ + -r --report= -s --smart= -o --offlineauto= -S \ + --saveauto= -H --health -c --capabilities -A \ + --attributes -l --log= -v --vendorattribute= -F \ + --firmwarebug= -P --presets= -t --test= -C \ + --captive -X --abort' -- $cur ) ) + else + cur=${cur:=/dev/} + _filedir + fi +} +complete -F _smartctl smartctl +} + +# vncviewer(1) completion +# +have vncviewer && +_vncviewer() +{ + local cur prev + local -a config + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -via) + _known_hosts -a + ;; + *) + # ssh into the the server, find and ping the broadcast address, then + # sort and show the results. + COMPREPLY=( $( ssh -o 'Batchmode yes' $prev \ + "ping -bnc 4 255.255.255.255" 2>/dev/null | \ + awk -F ' ' '{print $4}' | \ + sort -n | uniq | egrep '[0-9]+\.[0-9]+\.' 2>/dev/null ) ) + esac + + return 0 +} && +complete -F _vncviewer vncviewer + +# sysctl(8) completion +# +have sysctl && +_sysctl() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + COMPREPLY=( $( compgen -W "$(sysctl -N -a 2>/dev/null)" -- $cur ) ) + + return 0 +} && +complete -F _sysctl sysctl + +# update-rc.d(8) completion +# +# Copyright (C) 2004 Servilio Afre Puentes +# +have update-rc.d && +_update_rc_d() +{ + local cur prev sysvdir services options valid_options + + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \ + || sysvdir=/etc/init.d + + services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) ) + services=( ${services[@]#$sysvdir/} ) + options=( -f -n ) + + if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then + valid_options=( $( \ + echo "${COMP_WORDS[@]} ${options[@]}" \ + | tr " " "\n" \ + | sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" \ + | sort | uniq -u \ + ) ) + COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \ + -X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- $cur ) ) + elif [[ "$prev" == ?($( echo ${services[@]} | tr " " "|" )) ]]; then + COMPREPLY=( $( compgen -W 'remove defaults start stop' -- $cur ) ) + elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then + COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 ) + elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then + COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 ) + elif [[ "$prev" == defaults && -z "$cur" ]]; then + COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 s k ) + elif [[ "$prev" == ?(start|stop) ]]; then + if [[ "$cur" == [0-9] || -z "$cur" ]]; then + COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 ) + elif [[ "$cur" == [0-9][0-9] ]]; then + COMPREPLY=( $cur ) + else + COMPREPLY=() + fi + elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then + if [[ -z "$cur" ]]; then + if [[ $prev == [0-9][0-9] ]]; then + COMPREPLY=( 0 1 2 3 4 5 6 S ) + else + COMPREPLY=( 0 1 2 3 4 5 6 S . ) + fi + elif [[ "$cur" == [0-6S.] ]]; then + COMPREPLY=( $cur ) + else + COMPREPLY=() + fi + elif [[ "$prev" == "." ]]; then + COMPREPLY=( $(compgen -W "start stop" -- $cur) ) + else + COMPREPLY=() + fi + + return 0 +} && +complete -F _update_rc_d update-rc.d + +# invoke-rc.d(8) completion +# +# Copyright (C) 2004 Servilio Afre Puentes +# +have invoke-rc.d && +_invoke_rc_d() +{ + local cur prev sysvdir services options valid_options + + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \ + || sysvdir=/etc/init.d + + services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) ) + services=( ${services[@]#$sysvdir/} ) + options=( --help --quiet --force --try-anyway --disclose-deny --query --no-fallback ) + + if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then + valid_options=( $( \ + echo ${COMP_WORDS[@]} ${options[@]} \ + | tr " " "\n" \ + | sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" \ + | sort | uniq -u \ + ) ) + COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- \ + $cur ) ) + elif [ -x $sysvdir/$prev ]; then + COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \ + s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \ + $sysvdir/$prev`' -- \ + $cur ) ) + else + COMPREPLY=() + fi + + return 0 +} && +complete -F _invoke_rc_d invoke-rc.d + +# minicom(1) completion +# +have minicom && +_minicom() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + -@(a|c)) + COMPREPLY=( $( compgen -W 'on off' -- $cur ) ) + return 0 + ;; + -@(S|C)) + _filedir + return 0 + ;; + -P) + COMPREPLY=( $( command ls /dev/tty* ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' -- $cur ) ) + return 0 + ;; + esac + + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-s -o -m -M -z -l -L -w -a -t \ + -c -S -d -p -C -T -8' -- $cur ) ) + else + COMPREPLY=( $( command ls /etc/minicom/minirc.* 2>/dev/null | sed -e 's|/etc/minicom/minirc.||' | grep "^$cur" ) ) + fi +} && +complete -F _minicom minicom + +# svn completion +# +have svn && +{ +_svn() +{ + local cur prev commands options command + + COMPREPLY=() + cur=`_get_cword` + + commands='add blame praise annotate ann cat checkout co cleanup commit \ + ci copy cp delete del remove rm diff di export help ? h import \ + info list ls lock log merge mkdir move mv rename ren \ + propdel pdel pd propedit pedit pe propget pget pg \ + proplist plist pl propset pset ps resolved revert \ + status stat st switch sw unlock update up' + + if [[ $COMP_CWORD -eq 1 ]] ; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--version' -- $cur ) ) + else + COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) + fi + else + + prev=${COMP_WORDS[COMP_CWORD-1]} + case $prev in + --config-dir) + _filedir -d + return 0; + ;; + -@(F|-file|-targets)) + _filedir + return 0; + ;; + --encoding) + COMPREPLY=( $( compgen -W \ + '$( iconv --list | sed -e "s@//@@;" )' \ + -- "$cur" ) ) + return 0; + ;; + --@(editor|diff|diff3)-cmd) + COMP_WORDS=(COMP_WORDS[0] $cur) + COMP_CWORD=1 + _command + return 0; + ;; + esac + + command=${COMP_WORDS[1]} + + if [[ "$cur" == -* ]]; then + # possible options for the command + case $command in + add) + options='--auto-props --no-auto-props \ + --force --targets --no-ignore \ + --non-recursive -N -q --quiet' + ;; + @(blame|annotate|ann|praise)) + options='-r --revisions --username \ + --password --no-auth-cache \ + --non-interactive -v \ + --verbose --incremental --xml' + ;; + cat) + options='-r --revision --username \ + --password --no-auth-cache \ + --non-interactive' + ;; + @(checkout|co)) + options='-r --revision -q --quiet -N \ + --non-recursive --username \ + --password --no-auth-cache \ + --non-interactive \ + --ignore-externals' + ;; + cleanup) + options='--diff3-cmd' + ;; + @(commit|ci)) + options='-m --message -F --file \ + --encoding --force-log -q \ + --quiet --non-recursive -N \ + --targets --editor-cmd \ + --username --password \ + --no-auth-cache \ + --non-interactive --no-unlock' + ;; + @(copy|cp)) + options='-m --message -F --file \ + --encoding --force-log -r \ + --revision -q --quiet \ + --editor-cmd -username \ + --password --no-auth-cache \ + --non-interactive' + ;; + @(delete|del|remove|rm)) + options='--force -m --message -F \ + --file --encoding --force-log \ + -q --quiet --targets \ + --editor-cmd -username \ + --password --no-auth-cache \ + --non-interactive' + ;; + @(diff|di)) + options='-r --revision -x --extensions \ + --diff-cmd --no-diff-deleted \ + -N --non-recursive --username \ + --password --no-auth-cache \ + --non-interactive --force \ + --old --new --notice-ancestry' + ;; + export) + options='-r --revision -q --quiet \ + --username --password \ + --no-auth-cache \ + --non-interactive -N \ + --non-recursive --force \ + --native-eol --ignore-externals' + ;; + import) + options='--auto-props --no-auto-props \ + -m --message -F --file \ + --encoding --force-log -q \ + --quiet --non-recursive \ + --no-ignore --editor-cmd \ + --username --password \ + --no-auth-cache \ + --non-interactive' + ;; + info) + options='--username --password \ + --no-auth-cache \ + --non-interactive -r \ + --revision --xml --targets \ + -R --recursive --incremental' + ;; + @(list|ls)) + options='-r --revision -v --verbose -R \ + --recursive --username \ + --password --no-auth-cache \ + --non-interactive \ + --incremental --xml' + ;; + lock) + options='-m --message -F --file \ + --encoding --force-log \ + --targets --force --username \ + --password --no-auth-cache \ + --non-interactive' + ;; + log) + options='-r --revision -v --verbose \ + --targets --username \ + --password --no-auth-cache \ + --non-interactive \ + --stop-on-copy --incremental \ + --xml -q --quiet --limit' + ;; + merge) + options='-r --revision -N \ + --non-recursive -q --quiet \ + --force --dry-run --diff3-cmd \ + --username --password \ + --no-auth-cache \ + --non-interactive \ + --ignore-ancestry' + ;; + mkdir) + options='-m --message -F --file \ + --encoding --force-log -q \ + --quiet --editor-cmd \ + --username --password \ + --no-auth-cache \ + --non-interactive' + ;; + @(move|mv|rename|ren)) + options='-m --message -F --file \ + --encoding --force-log -r \ + --revision -q --quiet \ + --force --editor-cmd \ + --username --password \ + --no-auth-cache \ + --non-interactive' + ;; + @(propdel|pdel|pd)) + options='-q --quiet -R --recursive -r \ + --revision --revprop \ + --username --password \ + --no-auth-cache \ + --non-interactive' + ;; + @(propedit|pedit|pe)) + options='-r --revision --revprop \ + --encoding --editor-cmd \ + --username --password \ + --no-auth-cache \ + --non-interactive --force' + ;; + @(propget|pget|pg)) + options='-R --recursive -r --revision \ + --revprop --strict --username \ + --password --no-auth-cache \ + --non-interactive' + ;; + @(proplist|plist|pl)) + options='-v --verbose -R --recursive \ + -r --revision --revprop -q \ + --quiet --username --password \ + --no-auth-cache \ + --non-interactive' + ;; + @(propset|pset|ps)) + options='-F --file -q --quiet \ + --targets -R --recursive \ + --revprop --encoding \ + --username --password \ + --no-auth-cache \ + --non-interactive -r \ + --revision --force' + ;; + resolved) + options='--targets -R --recursive -q \ + --quiet' + ;; + revert) + options='--targets -R --recursive -q \ + --quiet' + ;; + @(status|stat|st)) + options='-u --show-updates -v \ + --verbose -N --non-recursive \ + -q --quiet --username \ + --password --no-auth-cache \ + --non-interactive --no-ignore \ + --ignore-externals \ + --incremental --xml' + ;; + @(switch|sw)) + options='--relocate -r --revision -N \ + --non-recursive -q --quiet \ + --username --password \ + --no-auth-cache \ + --non-interactive --diff3-cmd' + ;; + unlock) + options='--targets --force --username \ + --password --no-auth-cache \ + --non-interactive' + ;; + @(update|up)) + options='-r --revision -N \ + --non-recursive -q --quiet \ + --username --password \ + --no-auth-cache \ + --non-interactive \ + --diff3-cmd --ignore-externals' + ;; + esac + options="$options --help -h --config-dir" + + COMPREPLY=( $( compgen -W "$options" -- $cur ) ) + else + if [[ "$command" == @(help|h|\?) ]]; then + COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) + else + _filedir + fi + fi + fi + + return 0 +} +complete -F _svn $default svn + +_svnadmin() +{ + local cur prev commands options mode + + COMPREPLY=() + cur=`_get_cword` + + commands='create deltify dump help ? hotcopy list-dblogs \ + list-unused-dblogs load lslocks lstxns recover rmlocks \ + rmtxns setlog verify' + + if [[ $COMP_CWORD -eq 1 ]] ; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--version' -- $cur ) ) + else + COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) + fi + else + prev=${COMP_WORDS[COMP_CWORD-1]} + case $prev in + --config-dir) + _filedir -d + return 0; + ;; + --fs-type) + COMPREPLY=( $( compgen -W 'fsfs bdb' -- $cur ) ) + return 0; + ;; + esac + + command=${COMP_WORDS[1]} + + if [[ "$cur" == -* ]]; then + # possible options for the command + case $command in + create) + options='--bdb-txn-nosync \ + --bdb-log-keep --config-dir \ + --fs-type' + ;; + deltify) + options='-r --revision -q --quiet' + ;; + dump) + options='-r --revision --incremental \ + -q --quiet --deltas' + ;; + hotcopy) + options='--clean-logs' + ;; + load) + options='--ignore-uuid --force-uuid \ + --parent-dir -q --quiet \ + --use-pre-commit-hook \ + --use-post-commit-hook' + ;; + rmtxns) + options='-q --quiet' + ;; + setlog) + options='-r --revision --bypass-hooks' + ;; + esac + + options="$options --help -h" + COMPREPLY=( $( compgen -W "$options" -- $cur ) ) + else + if [[ "$command" == @(help|h|\?) ]]; then + COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) + else + _filedir + fi + fi + fi + + return 0 +} +complete -F _svnadmin $default svnadmin + +_svnlook() +{ + local cur prev commands options mode + + COMPREPLY=() + cur=`_get_cword` + + commands='author cat changed date diff dirs-changed help ? h history \ + info lock log propget pget pg proplist plist pl tree uuid \ + youngest' + + if [[ $COMP_CWORD -eq 1 ]] ; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--version' -- $cur ) ) + else + COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) + fi + else + command=${COMP_WORDS[1]} + + if [[ "$cur" == -* ]]; then + # possible options for the command + case $command in + @(author|cat|date|dirs-changed|info|log)) + options='-r --revision -t \ + --transaction' + ;; + changed) + options='-r --revision -t \ + --transaction --copy-info' + ;; + diff) + options='-r --revision -t \ + --transaction \ + --no-diff-deleted \ + --no-diff-added \ + --diff-copy-from' + ;; + history) + options='-r --revision --show-ids' + ;; + prop@(get|list)) + options='-r --revision -t \ + --transaction --revprop' + ;; + tree) + options='-r --revision -t \ + --transaction --show-ids \ + --full-paths' + ;; + esac + + options="$options --help -h" + COMPREPLY=( $( compgen -W "$options" -- $cur ) ) + else + if [[ "$command" == @(help|h|\?) ]]; then + COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) + else + _filedir + fi + fi + fi + + return 0 +} +complete -F _svnlook $default svnlook +} + +_filedir_xspec() +{ + local IFS cur xspec + + IFS=$'\t\n' + COMPREPLY=() + cur=`_get_cword` + + _expand || return 0 + + # get first exclusion compspec that matches this command + xspec=$( sed -ne $'/^complete .*[ \t]'${1##*/}$'\([ \t]\|$\)/{p;q;}' \ + $BASH_COMPLETION ) + # prune to leave nothing but the -X spec + xspec=${xspec#*-X } + xspec=${xspec%% *} + + local toks=( ) tmp + + while read -r tmp; do + [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp + done < <( compgen -d -- "$(quote_readline "$cur")" ) + + while read -r tmp; do + [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp + done < <( eval compgen -f -X $xspec -- "\$(quote_readline "\$cur")" ) + + COMPREPLY=( "${toks[@]}" ) +} +list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \ + $BASH_COMPLETION | \ + # read exclusion compspecs + ( + while read line + do + # ignore compspecs that are commented out + if [ "${line#\#}" != "$line" ]; then continue; fi + line=${line%# START exclude*} + line=${line%# FINISH exclude*} + line=${line##*\'} + list=( "${list[@]}" $line ) + done + echo "${list[@]}" + ) + ) ) +# remove previous compspecs +if [ ${#list[@]} -gt 0 ]; then + eval complete -r ${list[@]} + # install new compspecs + eval complete -F _filedir_xspec $filenames "${list[@]}" +fi +unset list + +# source completion directory definitions +if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \ + -x $BASH_COMPLETION_DIR ]; then + for i in $BASH_COMPLETION_DIR/*; do + [[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|.rpm*) ]] && + [ \( -f $i -o -h $i \) -a -r $i ] && . $i + done +fi +unset i + +# source user completion file +[ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \ + && . ~/.bash_completion +unset -f have +unset UNAME RELEASE default dirnames filenames have nospace bashdefault \ + plusdirs + +set $BASH_COMPLETION_ORIGINAL_V_VALUE +unset BASH_COMPLETION_ORIGINAL_V_VALUE + +### Local Variables: +### mode: shell-script +### End: diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/Solaris/etc.bash.bashrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/Solaris/etc.bash.bashrc Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,77 @@ +# +# This file contains an example of default settings that can be made for +# bash(1) users on this system. To make these settings the default for system +# users, you will need to copy it to /etc/bash/bashrc +# +# Bourne Again SHell init file. +# +umask 022 + +# Where's the Gnu stuff at? +GNU=/usr/gnu/bin +X11=/usr/X11/bin + +UTIL_PATH=$GNU:$X11 +STANDARD_PATH=/bin:/usr/bin:/sbin:/usr/sbin + +if [ -d $HOME/bin ]; then + MY_PATH=$MY_PATH:$HOME/bin +fi + +export PATH="$MY_PATH:$UTIL_PATH:$STANDARD_PATH" + +# If not running interactively, then return +if [ -z "$PS1" ]; then + return +fi + +# Set ignoreeof if you don't want EOF as the sole input to the shell to +# immediately signal a quit condition. This only happens at the start +# of a line if the line is empty, and you haven't just deleted a character +# with C-d. I turn this on in ~/.bash_profile so that only login shells +# have the right to be obnoxious. +set -o ignoreeof + +# Set auto_resume if you want to resume on "emacs", as well as on +# "%emacs". +auto_resume=exact + +# Set notify if you want to be asynchronously notified about background +# job completion. +set -o notify + +# Make it so that failed `exec' commands don't flush this shell. +shopt -s execfail + +if [ -z "$LOGIN_SHELL" ]; then + PS1="[\u@\h]:[\#]:[\w]:\$ " +fi + +HISTSIZE=256 +MAILCHECK=60 + +# +# we want pretty colored file listings +# +if [ -x /usr/bin/dircolors ] ; then + if [ -f ~/.dir_colors ] ; then + eval "`/usr/bin/dircolors -b ~/.dir_colors`" + elif [ -f ~/.dircolors ] ; then + eval "`/usr/bin/dircolors -b ~/.dircolors`" + fi +fi + +[ -f /etc/bash/bash_completion ] && . /etc/bash/bash_completion + +for s in /etc/bash/*.sh ; do + test -r $s && . $s +done + +for s in /etc/bash/*.bash ; do + test -r $s && . $s +done + +[ -f ~/.bash_expert ] && . ~/.bash_expert + +[ -f ~/.bash_aliases ] && . ~/.bash_aliases + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/Solaris/etc.bash.inputrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/Solaris/etc.bash.inputrc Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,338 @@ +# +# This file contains an example of default key binding that can be made for +# bash(1) users on this system. To make these settings the default for system +# users, you will need to copy it to /etc/bash/inputrc +# + +set meta-flag on +set input-meta on +set convert-meta off +set output-meta on + +$if mode=vi + set editing-mode vi + set keymap vi +$endif + +$if mode=emacs + $if term=xterm + "\e\eOD": backward-word + "\e\eOC": forward-word + "\e\eOA": up-history + "\e\eOB": down-history + "\C-\eOD": backward-char + "\C-\eOC": forward-char + "\C-\eOA": up-history + "\C-\eOB": down-history + $endif + "\e\e[D": backward-word + "\e\e[C": forward-word + "\e\e[A": up-history + "\e\e[B": down-history + "\C-\e[D": backward-char + "\C-\e[C": forward-char + "\C-\e[A": up-history + "\C-\e[B": down-history +$endif + +"\e[1~": beginning-of-line +"\e[2~": yank +"\e[3~": delete-char +"\e[4~": end-of-line +"\e[5~": history-search-backward +"\e[6~": history-search-forward +"\e[C": forward-char +"\e[D": backward-char +"\e[A": previous-history +"\e[B": next-history +"\C-?": backward-delete-char +"\C-H": backward-delete-char + +$if term=xterm + "\e[2;2~": yank + "\e[3;2~": delete-char + "\e[5;2~": history-search-backward + "\e[6;2~": history-search-forward + "\e[2;3~": yank + "\e[3;3~": delete-char + "\e[5;3~": history-search-backward + "\e[6;3~": history-search-forward + "\e[2;4~": yank + "\e[3;4~": delete-char + "\e[5;4~": history-search-backward + "\e[6;4~": history-search-forward + "\e[2;5~": yank + "\e[3;5~": delete-char + "\e[5;5~": history-search-backward + "\e[6;5~": history-search-forward + "\e[2;6~": yank + "\e[3;6~": delete-char + "\e[5;6~": history-search-backward + "\e[6;6~": history-search-forward + "\e[2;7~": yank + "\e[3;7~": delete-char + "\e[5;7~": history-search-backward + "\e[6;7~": history-search-forward + "\e[2;8~": yank + "\e[3;8~": delete-char + "\e[5;8~": history-search-backward + "\e[6;8~": history-search-forward + "\e[E": re-read-init-file + "\e[1;2E": re-read-init-file + "\e[1;3E": re-read-init-file + "\e[1;4E": re-read-init-file + "\e[1;5E": re-read-init-file + "\e[1;6E": re-read-init-file + "\e[1;7E": re-read-init-file + "\e[1;8E": re-read-init-file + "\e[2C": forward-word + "\e[2D": backward-word + "\e[2A": history-search-backward + "\e[2B": history-search-forward + "\e[1;2C": forward-word + "\e[1;2D": backward-word + "\e[1;2A": history-search-backward + "\e[1;2B": history-search-forward + "\e[1;3C": forward-word + "\e[1;3D": backward-word + "\e[1;3A": history-search-backward + "\e[1;3B": history-search-forward + "\e[1;4C": forward-word + "\e[1;4D": backward-word + "\e[1;4A": history-search-backward + "\e[1;4B": history-search-forward + "\e[5C": forward-word + "\e[5D": backward-word + "\e[5A": history-search-backward + "\e[5B": history-search-forward + "\e[1;5C": forward-word + "\e[1;5D": backward-word + "\e[1;5A": history-search-backward + "\e[1;5B": history-search-forward + "\e[1;6C": forward-word + "\e[1;6D": backward-word + "\e[1;6A": history-search-backward + "\e[1;6B": history-search-forward + "\e[1;7C": forward-word + "\e[1;7D": backward-word + "\e[1;7A": history-search-backward + "\e[1;7B": history-search-forward + "\e[1;8C": forward-word + "\e[1;8D": backward-word + "\e[1;8A": history-search-backward + "\e[1;8B": history-search-forward + "\e[1~": history-search-backward + "\e[4~": set-mark + "\e[H": beginning-of-line + "\e[F": end-of-line + "\e[1;2H": beginning-of-line + "\e[1;2F": end-of-line + "\e[1;3H": beginning-of-line + "\e[1;3F": end-of-line + "\e[1;4H": beginning-of-line + "\e[1;4F": end-of-line + "\e[1;5H": beginning-of-line + "\e[1;5F": end-of-line + "\e[1;6H": beginning-of-line + "\e[1;6F": end-of-line + "\e[1;7H": beginning-of-line + "\e[1;7F": end-of-line + "\e[1;8H": beginning-of-line + "\e[1;8F": end-of-line + "\e[2H": beginning-of-line + "\e[2F": end-of-line + "\e[5H": beginning-of-line + "\e[5F": end-of-line + "\eOH": beginning-of-line + "\eOF": end-of-line + "\eO2H": beginning-of-line + "\eO2F": end-of-line + "\eO5H": beginning-of-line + "\eO5F": end-of-line + "\eOD": backward-char + "\eOC": forward-char + "\eOA": previous-history + "\eOB": next-history + "\eOE": re-read-init-file + "\eO2D": backward-word + "\eO2C": forward-word + "\eO2A": history-search-backward + "\eO2B": history-search-forward + "\eO3D": backward-word + "\eO3C": forward-word + "\eO3A": history-search-backward + "\eO3B": history-search-forward + "\eO4D": backward-word + "\eO4C": forward-word + "\eO4A": history-search-backward + "\eO4B": history-search-forward + "\eO5D": backward-word + "\eO5C": forward-word + "\eO5A": history-search-backward + "\eO5B": history-search-forward + "\eO6D": backward-word + "\eO6C": forward-word + "\eO6A": history-search-backward + "\eO6B": history-search-forward + "\eO7D": backward-word + "\eO7C": forward-word + "\eO7A": history-search-backward + "\eO7B": history-search-forward + "\eO8D": backward-word + "\eO8C": forward-word + "\eO8A": history-search-backward + "\eO8B": history-search-forward + "\eOP": "\e" + "\eOQ": undo + "\eOR": "" + "\eOS": kill-line + "\eO2P": "\e" + "\eO2Q": undo + "\eO2R": "" + "\eO2S": kill-line + "\eO3P": "\e" + "\eO3Q": undo + "\eO3R": "" + "\eO3S": kill-line + "\eO4P": "\e" + "\eO4Q": undo + "\eO4R": "" + "\eO4S": kill-line + "\eO5P": "\e" + "\eO5Q": undo + "\eO5R": "" + "\eO5S": kill-line + "\eO6P": "\e" + "\eO6Q": undo + "\eO6R": "" + "\eO6S": kill-line + "\eO7P": "\e" + "\eO7Q": undo + "\eO7R": "" + "\eO7S": kill-line + "\eO8P": "\e" + "\eO8Q": undo + "\eO8R": "" + "\eO8S": kill-line + "\eO1;2P": "\e" + "\eO1;2Q": undo + "\eO1;2R": "" + "\eO1;2S": kill-line + "\eO1;3P": "\e" + "\eO1;3Q": undo + "\eO1;3R": "" + "\eO1;3S": kill-line + "\eO1;4P": "\e" + "\eO1;4Q": undo + "\eO1;4R": "" + "\eO1;4S": kill-line + "\eO1;5P": "\e" + "\eO1;5Q": undo + "\eO1;5R": "" + "\eO1;5S": kill-line + "\eO1;6P": "\e" + "\eO1;6Q": undo + "\eO1;6R": "" + "\eO1;6S": kill-line + "\eO1;7P": "\e" + "\eO1;7Q": undo + "\eO1;7R": "" + "\eO1;7S": kill-line + "\eO1;8P": "\e" + "\eO1;8Q": undo + "\eO1;8R": "" + "\eO1;8S": kill-line +$else + "\e[G": re-read-init-file + "\e[1~": beginning-of-line + "\e[4~": end-of-line +$endif +$if term=gnome + "\eOP": "\e" + "\eOQ": undo + "\eOR": "" + "\eOS": kill-line +$endif + +$if term=rxvt-unicode + "\e[23$": "" + "\e[24$": "" + "\e[11^": "" + "\e[12^": "" + "\e[13^": "" + "\e[14^": "" + "\e[15^": "" + "\e[17^": "" + "\e[18^": "" + "\e[19^": "" + "\e[20^": "" + "\e[21^": "" + "\e[23^": "" + "\e[24^": "" + "\eOo": "/" + "\eOj": "*" + "\eOm": "-" + "\eOk": "+" + "\eOl": "," + "\eOM": accept-line + "\eOn": "." + "\eOp": "0" + "\eOq": "1" + "\eOr": "2" + "\eOs": "3" + "\eOt": "4" + "\eOu": "5" + "\eOv": "6" + "\eOw": "7" + "\eOx": "8" + "\eOy": "9" + "\e\eOo": "" + "\e\eOj": "" + "\e\eOm": "" + "\e\eOk": "" + "\e\eOl": delete-char + "\e\eOM": accept-line + "\e\eOn": delete-char + "\e\eOp": yank + "\e\eOq": end-of-line + "\e\eOr": down-history + "\e\eOs": history-search-forward + "\e\eOt": backward-char + "\e\eOu": re-read-init-file + "\e\eOv": forward-char + "\e\eOw": beginning-of-line + "\e\eOx": up-history + "\e\eOy": history-search-backward + "\e[c": forward-word + "\e[d": backward-word + "\e[a": history-search-backward + "\e[b": history-search-forward + "\e\e[c": forward-word + "\e\e[d": backward-word + "\e\e[a": history-search-backward + "\e\e[b": history-search-forward + "\e\e[C": forward-word + "\e\e[D": backward-word + "\e\e[A": history-search-backward + "\e\e[B": history-search-forward + "\e[2^": yank + "\e[3^": delete-char + "\e[5^": history-search-backward + "\e[6^": history-search-forward + "\e[7^": beginning-of-line + "\e[8^": end-of-line + "\e[2$": yank + "\e[3$": delete-char + "\e[5$": history-search-backward + "\e[6$": history-search-forward + "\e[7$": beginning-of-line + "\e[8$": end-of-line + "\e\e[2$": yank + "\e\e[3$": delete-char + "\e\e[5$": history-search-backward + "\e\e[6$": history-search-forward + "\e\e[7$": beginning-of-line + "\e\e[8$": end-of-line + "\e=": accept-line +$endif + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/Solaris/rbash.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/Solaris/rbash.1 Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,247 @@ +'\" t +.\" +.\" Modified for Solaris to to add the Solaris stability classification, +.\" and to add a note about source availability. +.\" +.\" +.\" MAN PAGE COMMENTS to +.\" +.\" Chet Ramey +.\" Case Western Reserve University +.\" chet@po.cwru.edu +.\" +.\" Last Change: Sat Feb 7 20:50:40 EST 2009 +.\" +.\" bash_builtins, strip all but Built-Ins section +.if \n(zZ=1 .ig zZ +.if \n(zY=1 .ig zY +.TH RBASH 1 "2009 December 30" "GNU Bash-4.1" +.\" +.\" There's some problem with having a `@' +.\" in a tagged paragraph with the BSD man macros. +.\" It has to do with `@' appearing in the }1 macro. +.\" This is a problem on 4.3 BSD and Ultrix, but Sun +.\" appears to have fixed it. +.\" If you're seeing the characters +.\" `@u-3p' appearing before the lines reading +.\" `possible-hostname-completions +.\" and `complete-hostname' down in READLINE, +.\" then uncomment this redefinition. +.\" +.de }1 +.ds ]X \&\\*(]B\\ +.nr )E 0 +.if !"\\$1"" .nr )I \\$1n +.}f +.ll \\n(LLu +.in \\n()Ru+\\n(INu+\\n()Iu +.ti \\n(INu +.ie !\\n()Iu+\\n()Ru-\w\\*(]Xu-3p \{\\*(]X +.br\} +.el \\*(]X\h|\\n()Iu+\\n()Ru\c +.}f +.. +.\" +.\" File Name macro. This used to be `.PN', for Path Name, +.\" but Sun doesn't seem to like that very much. +.\" +.de FN +\fI\|\\$1\|\fP +.. +.SH NAME +rbash \- restricted bash, see \fBbash\fR(1) +.SH SYNOPSIS +.B rbash +.\" bash_builtins +.if \n(zZ=1 .ig zZ +.SH "RESTRICTED SHELL" +.\" rbash.1 +.zY +.PP +If +.B bash +is started with the name +.BR rbash , +or the +.B \-r +option is supplied at invocation, +the shell becomes restricted. +A restricted shell is used to +set up an environment more controlled than the standard shell. +It behaves identically to +.B bash +with the exception that the following are disallowed or not performed: +.IP \(bu +changing directories with \fBcd\fP +.IP \(bu +setting or unsetting the values of +.BR SHELL , +.BR PATH , +.BR ENV , +or +.B BASH_ENV +.IP \(bu +specifying command names containing +.B / +.IP \(bu +specifying a file name containing a +.B / +as an argument to the +.B . +builtin command +.IP \(bu +Specifying a filename containing a slash as an argument to the +.B \-p +option to the +.B hash +builtin command +.IP \(bu +importing function definitions from the shell environment at startup +.IP \(bu +parsing the value of \fBSHELLOPTS\fP from the shell environment at startup +.IP \(bu +redirecting output using the >, >|, <>, >&, &>, and >> redirection operators +.IP \(bu +using the +.B exec +builtin command to replace the shell with another command +.IP \(bu +adding or deleting builtin commands with the +.B \-f +and +.B \-d +options to the +.B enable +builtin command +.IP \(bu +Using the \fBenable\fP builtin command to enable disabled shell builtins +.IP \(bu +specifying the +.B \-p +option to the +.B command +builtin command +.IP \(bu +turning off restricted mode with +\fBset +r\fP or \fBset +o restricted\fP. +.PP +These restrictions are enforced after any startup files are read. +.PP +.ie \n(zY=1 When a command that is found to be a shell script is executed, +.el \{ When a command that is found to be a shell script is executed +(see +.SM +.B "COMMAND EXECUTION" +under bash(1)), +\} +.B rbash +turns off any restrictions in the shell spawned to execute the +script. +.\" end of rbash.1 +.if \n(zY=1 .ig zY +.SH "SEE ALSO" +.PD 0 +.TP +\fIBash Reference Manual\fP, Brian Fox and Chet Ramey +.TP +\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey +.TP +\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey +.TP +\fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE +.TP +\fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1) +.TP +\fIemacs\fP(1), \fIvi\fP(1) +.TP +\fIreadline\fP(3) +.PD +.SH FILES +.PD 0 +.TP +.FN /bin/bash +The \fBbash\fP executable +.TP +.FN /bin/rbash +The \fBrbash\fP executable +.TP +.FN /etc/profile +The systemwide initialization file, executed for login shells +.TP +.FN ~/.bash_profile +The personal initialization file, executed for login shells +.TP +.FN ~/.bashrc +The individual per-interactive-shell startup file +.TP +.FN ~/.bash_logout +The individual login shell cleanup file, executed when a login shell exits +.TP +.FN ~/.inputrc +Individual \fIreadline\fP initialization file +.PD +.SH AUTHORS +Brian Fox, Free Software Foundation +.br +bfox@gnu.org +.PP +Chet Ramey, Case Western Reserve University +.br +chet.ramey@case.edu +.SH BUG REPORTS +If you find a bug in +.B bash, +you should report it. But first, you should +make sure that it really is a bug, and that it appears in the latest +version of +.BR bash . +The latest version is always available from +\fIftp://ftp.gnu.org/pub/bash/\fP. +.PP +Once you have determined that a bug actually exists, use the +.I bashbug +command to submit a bug report. +If you have a fix, you are encouraged to mail that as well! +Suggestions and `philosophical' bug reports may be mailed +to \fIbug-bash@gnu.org\fP or posted to the Usenet +newsgroup +.BR gnu.bash.bug . +.PP +ALL bug reports should include: +.PP +.PD 0 +.TP 20 +The version number of \fBbash\fR +.TP +The hardware and operating system +.TP +The compiler used to compile +.TP +A description of the bug behaviour +.TP +A short script or `recipe' which exercises the bug +.PD +.PP +Comments and bug reports concerning +this manual page should be directed to +.IR chet@po.cwru.edu . +.\" Begin Sun update +.SH ATTRIBUTES +See +.BR attributes (5) +for descriptions of the following attributes: +.sp +.TS +box; +cbp-1 | cbp-1 +l | l . +ATTRIBUTE TYPE ATTRIBUTE VALUE += +Availability shell/bash += +Interface Stability External +.TE +.PP +.SH NOTES +Source for bash is available on http://opensolaris.org. +.\" End Sun update diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash.license --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash.license Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,1075 @@ +For the avoidance of doubt, except that if any license choice other than +GPL or LGPL is available it will apply instead, Oracle elects to use +only the General Public License version 3 (GPLv3) at this time for any +software where a choice of GPL license versions is made available with +the language indicating that GPLv3 or any later version may be used. +------------------------------------------------------------------ + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + +---------------------------------------------------------------------------- + +GNU Free Documentation License + +Version 1.2, November 2002 + + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, +or other functional and useful document "free" in the sense of +freedom: to assure everyone the effective freedom to copy and +redistribute it, with or without modifying it, either commercially or +noncommercially. Secondarily, this License preserves for the author +and publisher a way to get credit for their work, while not being +considered responsible for modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for +free software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, +that contains a notice placed by the copyright holder saying it can +be distributed under the terms of this License. Such a notice grants +a world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The "Document", below, refers +to any such manual or work. Any member of the public is a licensee, and +is addressed as "you". You accept the license if you copy, modify or +distribute the work in a way requiring permission under copyright law. + +A "Modified Version" of the Document means any work containing +the Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section +of the Document that deals exclusively with the relationship of +the publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says +that the Document is released under this License. A Front-Cover Text +may be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the general +public, that is suitable for revising the document straightforwardly +with generic text editors or (for images composed of pixels) generic +paint programs or (for drawings) some widely available drawing +editor, and that is suitable for input to text formatters or for +automatic translation to a variety of formats suitable for input to +text formatters. A copy made in an otherwise Transparent file format +whose markup, or absence of markup, has been arranged to thwart or +discourage subsequent modification by readers is not Transparent. An +image format is not Transparent if used for any substantial amount +of text. A copy that is not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the machine-generated +HTML, PostScript or PDF produced by some word processors for output +purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +A section "Entitled XYZ" means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for +a specific section name mentioned below, such as "Acknowledgements", +"Dedications", "Endorsements", or "History".) To "Preserve the Title" +of such a section when you modify the Document means that it remains +a section "Entitled XYZ" according to this definition. + +The Document may include Warranty Disclaimers next to the notice +which states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this License, +but only as regards disclaiming warranties: any other implication +that these Warranty Disclaimers may have is void and has no effect +on the meaning of this License. + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no +other conditions whatsoever to those of this License. You may not +use technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, +and you may publicly display copies. + +3. COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. Copying +with changes limited to the covers, as long as they preserve the +title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to +fit legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque +copy a computer-network location from which the general network-using +public has access to download using public-standard network protocols a +complete Transparent copy of the Document, free of added material. If +you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute +an Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + + * A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of previous + versions (which should, if there were any, be listed in the History + section of the Document). You may use the same title as a previous + version if the original publisher of that version gives permission. + * B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in the + Modified Version, together with at least five of the principal + authors of the Document (all of its principal authors, if it has + fewer than five), unless they release you from this requirement. + * C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + * D. Preserve all the copyright notices of the Document. + * E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + * F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified Version + under the terms of this License, in the form shown in the + Addendum below. + * G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's license + notice. + * H. Include an unaltered copy of this License. + * I. Preserve the section Entitled "History", Preserve its + Title, and add to it an item stating at least the title, year, + new authors, and publisher of the Modified Version as given + on the Title Page. If there is no section Entitled "History" + in the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, then + add an item describing the Modified Version as stated in the + previous sentence. + * J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for previous + versions it was based on. These may be placed in the "History" + section. You may omit a network location for a work that was + published at least four years before the Document itself, or if the + original publisher of the version it refers to gives permission. + * K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. + * L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers or + the equivalent are not considered part of the section titles. + * M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + * N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant Section. + * O. Preserve any Warranty Disclaimers. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or +all of these sections as invariant. To do this, add their titles +to the list of Invariant Sections in the Modified Version's license +notice. These titles must be distinct from any other section titles. + +You may add a section Entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of +a standard. + +You may add a passage of up to five words as a Front-Cover Text, +and a passage of up to 25 words as a Back-Cover Text, to the end of +the list of Cover Texts in the Modified Version. Only one passage +of Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, +and list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique +number. Make the same adjustment to the section titles in the list +of Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled "History" +in the various original documents, forming one section Entitled +"History"; likewise combine any sections Entitled "Acknowledgements", +and any sections Entitled "Dedications". You must delete all sections +Entitled "Endorsements." + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other +documents released under this License, and replace the individual +copies of this License in the various documents with a single copy +that is included in the collection, provided that you follow the rules +of this License for verbatim copying of each of the documents in all +other respects. + +You may extract a single document from such a collection, and +distribute it individually under this License, provided you insert +a copy of this License into the extracted document, and follow this +License in all other respects regarding verbatim copying of that +document. + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage +or distribution medium, is called an "aggregate" if the copyright +resulting from the compilation is not used to limit the legal rights of +the compilation's users beyond what the individual works permit. When +the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half +of the entire aggregate, the Document's Cover Texts may be placed +on covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic +form. Otherwise they must appear on printed covers that bracket the +whole aggregate. + +8. TRANSLATION + +Translation is considered a kind of modification, so you may distribute +translations of the Document under the terms of section 4. Replacing +Invariant Sections with translations requires special permission from +their copyright holders, but you may include translations of some or +all Invariant Sections in addition to the original versions of these +Invariant Sections. You may include a translation of this License, +and all the license notices in the Document, and any Warranty +Disclaimers, provided that you also include the original English +version of this License and the original versions of those notices +and disclaimers. In case of a disagreement between the translation +and the original version of this License or a notice or disclaimer, +the original version will prevail. + +If a section in the Document is Entitled "Acknowledgements", +"Dedications", or "History", the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual title. + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided for under this License. Any other attempt +to copy, modify, sublicense or distribute the Document is void, and +will automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such +new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. See +http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version +number. If the Document specifies that a particular numbered version +of this License "or any later version" applies to it, you have the +option of following the terms and conditions either of that specified +version or of any later version that has been published (not as a +draft) by the Free Software Foundation. If the Document does not +specify a version number of this License, you may choose any version +ever published (not as a draft) by the Free Software Foundation. +How to use this License for your documents + +To use this License in a document you have written, include a copy +of the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled + "GNU + Free Documentation License". + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being + LIST. + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice +of free software license, such as the GNU General Public License, +to permit their use in free software. + + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash.p5m Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,221 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +# +set name=pkg.fmri value=pkg:/shell/bash@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION) +set name=pkg.summary value="GNU Bourne-Again shell (bash) version 4.1" +set name=pkg.description value="GNU Bourne-Again shell (bash) version 4.1" +set name=info.classification value="org.opensolaris.category.2008:System/Shells" +set name=info.upstream_url value="http://www.gnu.org/software/bash/" +set name=info.source_url value=$(COMPONENT_ARCHIVE_URL) +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) +# +dir path=etc +dir path=etc/bash +dir path=etc/bash/bash_completion.d +dir path=usr +dir path=usr/bin +dir path=usr/gnu +dir path=usr/gnu/bin +dir path=usr/share +dir path=usr/share/bash +dir path=usr/share/info +dir path=usr/share/locale +dir path=usr/share/locale/af +dir path=usr/share/locale/af/LC_MESSAGES +dir path=usr/share/locale/bg +dir path=usr/share/locale/bg/LC_MESSAGES +dir path=usr/share/locale/ca +dir path=usr/share/locale/ca/LC_MESSAGES +dir path=usr/share/locale/cs +dir path=usr/share/locale/cs/LC_MESSAGES +dir path=usr/share/locale/de +dir path=usr/share/locale/de/LC_MESSAGES +dir path=usr/share/locale/en +dir path=usr/share/locale/en/LC_MESSAGES +dir path=usr/share/locale/en_CA +dir path=usr/share/locale/en_CA/LC_MESSAGES +dir path=usr/share/locale/en_GB +dir path=usr/share/locale/en_GB/LC_MESSAGES +dir path=usr/share/locale/eo +dir path=usr/share/locale/eo/LC_MESSAGES +dir path=usr/share/locale/es +dir path=usr/share/locale/es/LC_MESSAGES +dir path=usr/share/locale/et +dir path=usr/share/locale/et/LC_MESSAGES +dir path=usr/share/locale/fr +dir path=usr/share/locale/fr/LC_MESSAGES +dir path=usr/share/locale/hu +dir path=usr/share/locale/hu/LC_MESSAGES +dir path=usr/share/locale/id +dir path=usr/share/locale/id/LC_MESSAGES +dir path=usr/share/locale/ja +dir path=usr/share/locale/ja/LC_MESSAGES +dir path=usr/share/locale/lt +dir path=usr/share/locale/lt/LC_MESSAGES +dir path=usr/share/locale/nl +dir path=usr/share/locale/nl/LC_MESSAGES +dir path=usr/share/locale/pl +dir path=usr/share/locale/pl/LC_MESSAGES +dir path=usr/share/locale/pt_BR +dir path=usr/share/locale/pt_BR/LC_MESSAGES +dir path=usr/share/locale/ro +dir path=usr/share/locale/ro/LC_MESSAGES +dir path=usr/share/locale/ru +dir path=usr/share/locale/ru/LC_MESSAGES +dir path=usr/share/locale/sk +dir path=usr/share/locale/sk/LC_MESSAGES +dir path=usr/share/locale/sv +dir path=usr/share/locale/sv/LC_MESSAGES +dir path=usr/share/locale/tr +dir path=usr/share/locale/tr/LC_MESSAGES +dir path=usr/share/locale/vi +dir path=usr/share/locale/vi/LC_MESSAGES +dir path=usr/share/locale/zh_TW +dir path=usr/share/locale/zh_TW/LC_MESSAGES +dir path=usr/share/man +dir path=usr/share/man/man1 +# +file path=etc/bash/bashrc.example +file path=etc/bash/bash_completion.example +file path=etc/bash/inputrc.example +file path=usr/bin/bash +file path=usr/share/bash/alias +file path=usr/share/bash/arith +file path=usr/share/bash/arith_for +file path=usr/share/bash/bg +file path=usr/share/bash/bind +file path=usr/share/bash/break +file path=usr/share/bash/builtin +file path=usr/share/bash/caller +file path=usr/share/bash/case +file path=usr/share/bash/cd +file path=usr/share/bash/colon +file path=usr/share/bash/command +file path=usr/share/bash/compgen +file path=usr/share/bash/complete +file path=usr/share/bash/compopt +file path=usr/share/bash/conditional +file path=usr/share/bash/continue +file path=usr/share/bash/coproc +file path=usr/share/bash/declare +file path=usr/share/bash/dirs +file path=usr/share/bash/disown +file path=usr/share/bash/dot +file path=usr/share/bash/echo +file path=usr/share/bash/enable +file path=usr/share/bash/eval +file path=usr/share/bash/exec +file path=usr/share/bash/exit +file path=usr/share/bash/export +file path=usr/share/bash/false +file path=usr/share/bash/fc +file path=usr/share/bash/fg +file path=usr/share/bash/fg_percent +file path=usr/share/bash/for +file path=usr/share/bash/function +file path=usr/share/bash/getopts +file path=usr/share/bash/grouping_braces +file path=usr/share/bash/hash +file path=usr/share/bash/help +file path=usr/share/bash/history +file path=usr/share/bash/if +file path=usr/share/bash/jobs +file path=usr/share/bash/kill +file path=usr/share/bash/let +file path=usr/share/bash/local +file path=usr/share/bash/logout +file path=usr/share/bash/mapfile +file path=usr/share/bash/popd +file path=usr/share/bash/printf +file path=usr/share/bash/pushd +file path=usr/share/bash/pwd +file path=usr/share/bash/read +file path=usr/share/bash/readarray +file path=usr/share/bash/readonly +file path=usr/share/bash/return +file path=usr/share/bash/select +file path=usr/share/bash/set +file path=usr/share/bash/shift +file path=usr/share/bash/shopt +file path=usr/share/bash/source +file path=usr/share/bash/suspend +file path=usr/share/bash/test +file path=usr/share/bash/test_bracket +file path=usr/share/bash/time +file path=usr/share/bash/times +file path=usr/share/bash/trap +file path=usr/share/bash/true +file path=usr/share/bash/type +file path=usr/share/bash/typeset +file path=usr/share/bash/ulimit +file path=usr/share/bash/umask +file path=usr/share/bash/unalias +file path=usr/share/bash/unset +file path=usr/share/bash/until +file path=usr/share/bash/variable_help +file path=usr/share/bash/wait +file path=usr/share/bash/while +file path=usr/share/locale/af/LC_MESSAGES/bash.mo +file path=usr/share/locale/bg/LC_MESSAGES/bash.mo +file path=usr/share/locale/ca/LC_MESSAGES/bash.mo +file path=usr/share/locale/cs/LC_MESSAGES/bash.mo +file path=usr/share/locale/de/LC_MESSAGES/bash.mo +file path=usr/share/locale/en/LC_MESSAGES/bash.mo +file path=usr/share/locale/en@boldquot/LC_MESSAGES/bash.mo +file path=usr/share/locale/en@quot/LC_MESSAGES/bash.mo +file path=usr/share/locale/en_CA/LC_MESSAGES/bash.mo +file path=usr/share/locale/en_GB/LC_MESSAGES/bash.mo +file path=usr/share/locale/eo/LC_MESSAGES/bash.mo +file path=usr/share/locale/es/LC_MESSAGES/bash.mo +file path=usr/share/locale/et/LC_MESSAGES/bash.mo +file path=usr/share/locale/fr/LC_MESSAGES/bash.mo +file path=usr/share/locale/hu/LC_MESSAGES/bash.mo +file path=usr/share/locale/id/LC_MESSAGES/bash.mo +file path=usr/share/locale/ja/LC_MESSAGES/bash.mo +file path=usr/share/locale/lt/LC_MESSAGES/bash.mo +file path=usr/share/locale/nl/LC_MESSAGES/bash.mo +file path=usr/share/locale/pl/LC_MESSAGES/bash.mo +file path=usr/share/locale/pt_BR/LC_MESSAGES/bash.mo +file path=usr/share/locale/ro/LC_MESSAGES/bash.mo +file path=usr/share/locale/ru/LC_MESSAGES/bash.mo +file path=usr/share/locale/sk/LC_MESSAGES/bash.mo +file path=usr/share/locale/sv/LC_MESSAGES/bash.mo +file path=usr/share/locale/tr/LC_MESSAGES/bash.mo +file path=usr/share/locale/vi/LC_MESSAGES/bash.mo +file path=usr/share/locale/zh_TW/LC_MESSAGES/bash.mo +file path=usr/share/man/man1/bash.1 +file path=usr/share/man/man1/rbash.1 +file path=usr/share/info/bash.info +# +link path=usr/bin/rbash target=./bash +link path=usr/gnu/bin/sh target=../../bin/bash +# +license bash.license license="GPLv3, FDLv1.2" +# +legacy pkg=SUNWbash \ + desc="GNU Bourne-Again shell (bash) version 4.1" \ + name="GNU Bourne-Again shell (bash)" + +legacy pkg=SUNWbashr \ + desc="GNU Bourne-Again shell (bash) version 4.1 (root package)" \ + name="GNU Bourne-Again shell (bash) (root)" + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash41-001.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash41-001.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,48 @@ + BASH PATCH REPORT + ================= + +Bash-Release: 4.1 +Patch-ID: bash41-001 + +Bug-Reported-by: Yann Rouillard +Bug-Reference-ID: <4B44A410.4070107@pleiades.fr.eu.org> +Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2010-01/msg00018.html + +Bug-Description: + +A prototype for vsnprintf was incorrect, and caused compilation failures +on systems that did not have a suitable vsnprintf, but had a declaration in +one of the system header files. + +Patch (apply with `patch -p0'): + +*** ../bash-4.1-patched/builtins/printf.def 2009-11-20 15:31:23.000000000 -0500 +--- builtins/printf.def 2010-01-07 08:50:06.000000000 -0500 +*************** +*** 173,177 **** + + #if !HAVE_VSNPRINTF +! extern int vsnprintf __P((char *, size_t, const char *, ...)) __attribute__((__format__ (printf, 3, 4))); + #endif + +--- 173,177 ---- + + #if !HAVE_VSNPRINTF +! extern int vsnprintf __P((char *, size_t, const char *, va_list)) __attribute__((__format__ (printf, 3, 0))); + #endif + +*** ../bash-4.1-patched/patchlevel.h 2009-10-01 16:39:22.000000000 -0400 +--- patchlevel.h 2010-01-14 09:38:08.000000000 -0500 +*************** +*** 26,30 **** + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 0 + + #endif /* _PATCHLEVEL_H_ */ +--- 26,30 ---- + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 1 + + #endif /* _PATCHLEVEL_H_ */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash41-002.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash41-002.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,65 @@ + BASH PATCH REPORT + ================= + +Bash-Release: 4.1 +Patch-ID: bash41-002 + +Bug-Reported-by: guillaume.outters@free.fr +Bug-Reference-ID: <20100105230441.70D171AA7F52@asterix.local> +Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2010-01/msg00017.html + +Bug-Description: + +Bash-4.1/Readline-6.1 introduced a hook function that allows applications +to rewrite or modify filenames read from the file system before comparing +them with a word to be completed. The converted filename, if it matches, +needs to be inserted into the line buffer, replacing the original contents. + +This fixes a completion bug on Mac OS X involving filenames containing +UTF-8 characters. + +Patch (apply with `patch -p0'): + +*** ../bash-4.1-patched/lib/readline/complete.c 2009-11-29 18:39:30.000000000 -0500 +--- lib/readline/complete.c 2010-01-06 08:30:23.000000000 -0500 +*************** +*** 2139,2143 **** + if (filename_len == 0) + { +! if (_rl_match_hidden_files == 0 && HIDDEN_FILE (entry->d_name)) + continue; + +--- 2139,2143 ---- + if (filename_len == 0) + { +! if (_rl_match_hidden_files == 0 && HIDDEN_FILE (convfn)) + continue; + +*************** +*** 2220,2224 **** + } + +! strcpy (temp + dirlen, entry->d_name); + } + else +--- 2220,2224 ---- + } + +! strcpy (temp + dirlen, convfn); + } + else +*** ../bash-4.1-patched/patchlevel.h 2009-10-01 16:39:22.000000000 -0400 +--- patchlevel.h 2010-01-14 09:38:08.000000000 -0500 +*************** +*** 26,30 **** + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 1 + + #endif /* _PATCHLEVEL_H_ */ +--- 26,30 ---- + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 2 + + #endif /* _PATCHLEVEL_H_ */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash41-003.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash41-003.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,48 @@ + BASH PATCH REPORT + ================= + +Bash-Release: 4.1 +Patch-ID: bash41-003 + +Bug-Reported-by: coyote@wariat.org.pl +Bug-Reference-ID: <4b64a1f8.06e2660a.60af.4bfb@mx.google.com> +Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2010-01/msg00135.html + +Bug-Description: + +If command completion is attempted on a word with a quoted globbing +character (e.g., `*' or `?'), bash can reference a NULL pointer and +dump core. + +Patch (apply with `patch -p0'): + +*** ../bash-4.1-patched/bashline.c 2009-10-24 14:10:19.000000000 -0400 +--- bashline.c 2010-01-30 21:53:49.000000000 -0500 +*************** +*** 1681,1685 **** + characters in the common prefix are bad) will ever be returned on + regular completion. */ +! if (glob_pattern_p (hint)) + { + if (state == 0) +--- 1681,1685 ---- + characters in the common prefix are bad) will ever be returned on + regular completion. */ +! if (globpat) + { + if (state == 0) +*** ../bash-4.1-patched/patchlevel.h 2009-10-01 16:39:22.000000000 -0400 +--- patchlevel.h 2010-01-14 09:38:08.000000000 -0500 +*************** +*** 26,30 **** + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 2 + + #endif /* _PATCHLEVEL_H_ */ +--- 26,30 ---- + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 3 + + #endif /* _PATCHLEVEL_H_ */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash41-004.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash41-004.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,47 @@ + BASH PATCH REPORT + ================= + +Bash-Release: 4.1 +Patch-ID: bash41-004 + +Bug-Reported-by: Crestez Dan Leonard +Bug-Reference-ID: <1265592839.30682.21.camel@deskbox> +Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2010-02/msg00034.html + +Bug-Description: + +When running in Posix mode and executing a shell function without local +variables, bash will not propagate a variable in a special builtin's temporary +environment to have global scope. + +Patch (apply with `patch -p0'): + +*** ../bash-4.1-patched/variables.c 2009-11-03 14:13:58.000000000 -0500 +--- variables.c 2010-02-08 17:36:18.000000000 -0500 +*************** +*** 3809,3812 **** +--- 3809,3817 ---- + if (tempvar_p (var) && (posixly_correct || (var->attributes & att_propagate))) + { ++ /* Make sure we have a hash table to store the variable in while it is ++ being propagated down to the global variables table. Create one if ++ we have to */ ++ if ((vc_isfuncenv (shell_variables) || vc_istempenv (shell_variables)) && shell_variables->table == 0) ++ shell_variables->table = hash_create (0); + /* XXX - should we set v->context here? */ + v = bind_variable_internal (var->name, value_cell (var), shell_variables->table, 0, 0); +*** ../bash-4.1-patched/patchlevel.h 2009-10-01 16:39:22.000000000 -0400 +--- patchlevel.h 2010-01-14 09:38:08.000000000 -0500 +*************** +*** 26,30 **** + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 3 + + #endif /* _PATCHLEVEL_H_ */ +--- 26,30 ---- + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 4 + + #endif /* _PATCHLEVEL_H_ */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash41-005.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash41-005.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,56 @@ + BASH PATCH REPORT + ================= + +Bash-Release: 4.1 +Patch-ID: bash41-005 + +Bug-Reported-by: werner@suse.de +Bug-Reference-ID: <201002251238.o1PCcYcg016893@boole.suse.de> +Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2010-02/msg00132.html + +Bug-Description: + +When the `read' builtin times out after the timeout specified with -t is +exceeded, it does not reset the flags that tell signal handlers to process +signals immediately instead of deferring their handling. This can result +in unsafe functions being called from signal handlers, which can cause bash +to hang or dump core. + +Patch (apply with `patch -p0'): + +*** ../bash-4.1-patched/builtins/read.def 2009-10-08 11:35:46.000000000 -0400 +--- builtins/read.def 2010-03-17 17:35:39.000000000 -0400 +*************** +*** 616,621 **** + zsyncfd (fd); + +- interrupt_immediately--; +- terminate_immediately--; + discard_unwind_frame ("read_builtin"); + +--- 616,619 ---- +*************** +*** 624,627 **** +--- 622,628 ---- + assign_vars: + ++ interrupt_immediately--; ++ terminate_immediately--; ++ + #if defined (ARRAY_VARS) + /* If -a was given, take the string read, break it into a list of words, +*** ../bash-4.1-patched/patchlevel.h 2009-10-01 16:39:22.000000000 -0400 +--- patchlevel.h 2010-01-14 09:38:08.000000000 -0500 +*************** +*** 26,30 **** + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 4 + + #endif /* _PATCHLEVEL_H_ */ +--- 26,30 ---- + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 5 + + #endif /* _PATCHLEVEL_H_ */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash41-006.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash41-006.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,76 @@ + BASH PATCH REPORT + ================= + +Bash-Release: 4.1 +Patch-ID: bash41-006 + +Bug-Reported-by: Mike Frysinger +Bug-Reference-ID: <201003210155.56618.vapier@gentoo.org> +Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2010-03/msg00063.html + +Bug-Description: + +Bash did not correctly print/reproduce here documents attached to commands +inside compound commands such as for and while. This affected the +execution of such commands inside a shell function when the function +definition is saved and later restored using `.' or `eval'. + +Patch (apply with `patch -p0'): + +*** ../bash-4.1-patched/print_cmd.c 2009-09-16 15:32:26.000000000 -0400 +--- print_cmd.c 2010-03-22 21:15:30.000000000 -0400 +*************** +*** 114,117 **** +--- 114,123 ---- + #define CHECK_XTRACE_FP xtrace_fp = (xtrace_fp ? xtrace_fp : stderr) + ++ #define PRINT_DEFERRED_HEREDOCS(x) \ ++ do { \ ++ if (deferred_heredocs) \ ++ print_deferred_heredocs (x); \ ++ } while (0) ++ + /* Non-zero means the stuff being printed is inside of a function def. */ + static int inside_function_def; +*************** +*** 561,571 **** + { + print_for_command_head (for_command); +- + cprintf (";"); + newline ("do\n"); + indentation += indentation_amount; + make_command_string_internal (for_command->action); + semicolon (); + indentation -= indentation_amount; + newline ("done"); + } +--- 566,578 ---- + { + print_for_command_head (for_command); + cprintf (";"); + newline ("do\n"); ++ + indentation += indentation_amount; + make_command_string_internal (for_command->action); ++ PRINT_DEFERRED_HEREDOCS (""); + semicolon (); + indentation -= indentation_amount; ++ + newline ("done"); + } +*** ../bash-4.1-patched/patchlevel.h 2009-10-01 16:39:22.000000000 -0400 +--- patchlevel.h 2010-01-14 09:38:08.000000000 -0500 +*************** +*** 26,30 **** + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 5 + + #endif /* _PATCHLEVEL_H_ */ +--- 26,30 ---- + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 6 + + #endif /* _PATCHLEVEL_H_ */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash41-007.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash41-007.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,47 @@ + BASH PATCH REPORT + ================= + +Bash-Release: 4.1 +Patch-ID: bash41-007 + +Bug-Reported-by: Rob Robason +Bug-Reference-ID: <1269513145.22336.9.camel@home.robason.homelinux.net> +Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2010-03/msg00089.html + +Bug-Description: + +A typo caused bash to not honor a precision specification in a printf +format. + +Patch (apply with `patch -p0'): + +*** ../bash-4.1-patched/builtins/printf.def 2010-01-18 10:50:22.000000000 -0500 +--- builtins/printf.def 2010-03-25 09:40:56.000000000 -0400 +*************** +*** 118,122 **** + nw = vflag ? vbprintf (f, fieldwidth, func) : printf (f, fieldwidth, func); \ + else if (have_precision) \ +! nw = vflag ? vbprintf (f, precision, func) : printf (f, fieldwidth, func); \ + else \ + nw = vflag ? vbprintf (f, func) : printf (f, func); \ +--- 118,122 ---- + nw = vflag ? vbprintf (f, fieldwidth, func) : printf (f, fieldwidth, func); \ + else if (have_precision) \ +! nw = vflag ? vbprintf (f, precision, func) : printf (f, precision, func); \ + else \ + nw = vflag ? vbprintf (f, func) : printf (f, func); \ +*** ../bash-4.1-patched/patchlevel.h 2009-10-01 16:39:22.000000000 -0400 +--- patchlevel.h 2010-01-14 09:38:08.000000000 -0500 +*************** +*** 26,30 **** + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 6 + + #endif /* _PATCHLEVEL_H_ */ +--- 26,30 ---- + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 7 + + #endif /* _PATCHLEVEL_H_ */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash41-008.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash41-008.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,49 @@ + BASH PATCH REPORT + ================= + +Bash-Release: 4.1 +Patch-ID: bash41-008 + +Bug-Reported-by: Dennis van Dok +Bug-Reference-ID: <4BBF2501.5050703@gmail.com> +Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2010-04/msg00038.html + +Bug-Description: + +When declaring an associative array and implicitly assigning a value +to element "0", bash does not correctly allocate memory, leading to +a segmentation violation when that element or the array itself is +unset. + +Patch (apply with `patch -p0'): + +*** ../bash-4.1-patched/builtins/declare.def 2009-11-25 19:42:00.000000000 -0500 +--- builtins/declare.def 2010-05-30 18:25:21.000000000 -0400 +*************** +*** 513,517 **** + /* let bind_{array,assoc}_variable take care of this. */ + if (assoc_p (var)) +! bind_assoc_variable (var, name, "0", value, aflags); + else + bind_array_variable (name, 0, value, aflags); +--- 519,523 ---- + /* let bind_{array,assoc}_variable take care of this. */ + if (assoc_p (var)) +! bind_assoc_variable (var, name, savestring ("0"), value, aflags); + else + bind_array_variable (name, 0, value, aflags); +*** ../bash-4.1-patched/patchlevel.h 2009-10-01 16:39:22.000000000 -0400 +--- patchlevel.h 2010-01-14 09:38:08.000000000 -0500 +*************** +*** 26,30 **** + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 7 + + #endif /* _PATCHLEVEL_H_ */ +--- 26,30 ---- + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 8 + + #endif /* _PATCHLEVEL_H_ */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/bash41-009.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/bash41-009.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,48 @@ + BASH PATCH REPORT + ================= + +Bash-Release: 4.1 +Patch-ID: bash41-009 + +Bug-Reported-by: Tomas Trnka +Bug-Reference-ID: <201003242030.02166.tomastrnka@gmx.com> +Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2010-03/msg00090.html + +Bug-Description: + +An arriving SIGCHLD will interrupt `slow' system calls such as write(2) to +or read(2) from a terminal. This results in an error message and truncated +input or output. + +Patch (apply with `patch -p0'): + +*** ../bash-4.1-patched/sig.c Fri Aug 14 16:31:52 2009 +--- sig.c Fri Mar 26 22:34:11 2010 +*************** +*** 655,660 **** +--- 655,663 ---- + act.sa_flags |= SA_INTERRUPT; /* XXX */ + else + act.sa_flags |= SA_RESTART; /* XXX */ ++ #else ++ if (sig == SIGCHLD) ++ act.sa_flags |= SA_RESTART; + #endif + sigemptyset (&act.sa_mask); + sigemptyset (&oact.sa_mask); +*** ../bash-4.1-patched/patchlevel.h 2009-10-01 16:39:22.000000000 -0400 +--- patchlevel.h 2010-01-14 09:38:08.000000000 -0500 +*************** +*** 26,30 **** + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 8 + + #endif /* _PATCHLEVEL_H_ */ +--- 26,30 ---- + looks for to find the patch level (for the sccs version string). */ + +! #define PATCHLEVEL 9 + + #endif /* _PATCHLEVEL_H_ */ + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/oracleman-stability --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/oracleman-stability Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,27 @@ +1i\ +'\\" t\ +\.\\"\ +\.\\" Modified for Solaris to to add the Solaris stability classification,\ +\.\\" and to add a note about source availability.\ +\.\\"\ +$a\ +\.\\" Begin Oracle update\ +.SH ATTRIBUTES\ +See\ +.BR attributes (5)\ +for descriptions of the following attributes:\ +.sp\ +.TS\ +box;\ +cbp-1 | cbp-1\ +l | l .\ +ATTRIBUTE TYPE ATTRIBUTE VALUE\ +=\ +Availability shell/bash \ +=\ +Interface Stability External \ +.TE \ +.PP\ +.SH NOTES\ +Source for bash is available on http://opensolaris.org.\ +\.\\" End Oracle update diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-000.config.h.in.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-000.config.h.in.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,11 @@ +--- config.h.in 2009-08-18 20:34:36.000000000 -0700 ++++ config.h.in 2010-09-01 10:21:00.756734104 -0700 +@@ -21,6 +21,8 @@ + #ifndef _CONFIG_H_ + #define _CONFIG_H_ + ++#include "config-top.h" ++ + /* Configuration feature settings controllable by autoconf. */ + + /* Define JOB_CONTROL if your operating system supports diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-001.config-top.h.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-001.config-top.h.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,37 @@ +--- config-top.h 2009-12-22 12:29:39.000000000 -0800 ++++ config-top.h 2010-09-01 10:24:03.070928602 -0700 +@@ -54,14 +54,14 @@ + /* The default value of the PATH variable. */ + #ifndef DEFAULT_PATH_VALUE + #define DEFAULT_PATH_VALUE \ +- "/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:." ++ "/usr/gnu/bin:/bin:/usr/bin:/sbin:/usr/sbin:." + #endif + + /* The value for PATH when invoking `command -p'. This is only used when + the Posix.2 confstr () function, or CS_PATH define are not present. */ + #ifndef STANDARD_UTILS_PATH + #define STANDARD_UTILS_PATH \ +- "/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc" ++ "/usr/gnu/bin:/bin:/usr/bin:/sbin:/usr/sbin:/etc:/etc/bash" + #endif + + /* Default primary and secondary prompt strings. */ +@@ -75,14 +75,14 @@ + #define KSH_COMPATIBLE_SELECT + + /* System-wide .bashrc file for interactive shells. */ +-/* #define SYS_BASHRC "/etc/bash.bashrc" */ ++#define SYS_BASHRC "/etc/bash/bashrc" + + /* System-wide .bash_logout for login shells. */ +-/* #define SYS_BASH_LOGOUT "/etc/bash.bash_logout" */ ++#define SYS_BASH_LOGOUT "/etc/bash/bash_logout" + + /* Define this to make non-interactive shells begun with argv[0][0] == '-' + run the startup files when not in posix mode. */ +-/* #define NON_INTERACTIVE_LOGIN_SHELLS */ ++#define NON_INTERACTIVE_LOGIN_SHELLS 1 + + /* Define this if you want bash to try to check whether it's being run by + sshd and source the .bashrc if so (like the rshd behavior). This checks diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-002.Makefile.in.3.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-002.Makefile.in.3.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,35 @@ +--- Makefile.in 2009-12-30 10:05:40.000000000 -0800 ++++ Makefile.in 2011-02-04 16:31:01.659698136 -0800 +@@ -137,7 +137,7 @@ + STATIC_LD = @STATIC_LD@ + LOCAL_LDFLAGS = @LOCAL_LDFLAGS@ + +-SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS) ++SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS) $(CFLAGS) + + BASE_CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \ + $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) +@@ -535,7 +535,7 @@ + + $(Program): .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP) + $(RM) $@ +- $(PURIFY) $(CC) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS) ++ $(PURIFY) $(CC) $(CFLAGS) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS) $(LD_OPTIONS) -s + ls -l $(Program) + -$(SIZE) $(Program) + +@@ -549,10 +549,10 @@ + @echo + + bashbug: $(SUPPORT_SRC)bashbug.sh config.h Makefile $(VERSPROG) +- @sed -e "s%!MACHINE!%$(Machine)%" -e "s%!OS!%$(OS)%" \ +- -e "s%!CFLAGS!%$(CCFLAGS)%" -e "s%!CC!%$(CC)%" \ +- -e "s%!RELEASE!%$(Version)%" -e "s%!PATCHLEVEL!%$(PatchLevel)%" \ +- -e "s%!MACHTYPE!%$(MACHTYPE)%" -e "s%!RELSTATUS!%$(RELSTATUS)%" \ ++ @sed -e "s^!MACHINE!^$(Machine)^" -e "s^!OS!^$(OS)^" \ ++ -e "s^!CFLAGS!^$(CCFLAGS)^" -e "s^!CC!^$(CC)^" \ ++ -e "s^!RELEASE!^$(Version)^" -e "s^!PATCHLEVEL!^$(PatchLevel)^" \ ++ -e "s^!MACHTYPE!^$(MACHTYPE)^" -e "s^!RELSTATUS!^$(RELSTATUS)^" \ + $(SUPPORT_SRC)bashbug.sh > $@ + @chmod a+rx bashbug + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-003.glob.c.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-003.glob.c.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,13 @@ +--- lib/glob/glob.c 2009-11-14 15:39:30.000000000 -0800 ++++ lib/glob/glob.c 2010-09-01 10:28:10.161379481 -0700 +@@ -34,6 +34,10 @@ + # include + #endif + ++#if defined (HAVE_ALLOCA) && defined (HAVE_ALLOCA_H) ++# include ++#endif ++ + #include "bashansi.h" + #include "posixdir.h" + #include "posixstat.h" diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-004.snprintf.c.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-004.snprintf.c.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,11 @@ +--- lib/sh/snprintf.c 2008-08-12 12:02:14.000000000 -0400 ++++ lib/sh/snprintf.c 2009-08-10 15:16:30.000000000 -0400 +@@ -116,6 +116,8 @@ + # include + #endif + ++#include ++ + #include "stdc.h" + #include + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-005.variables.c.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-005.variables.c.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,17 @@ +--- variables.c 2009-01-04 14:32:46.000000000 -0500 ++++ variables.c 2009-08-15 14:53:56.426776000 -0400 +@@ -402,14 +402,10 @@ + /* Now make our own defaults in case the vars that we think are + important are missing. */ + temp_var = set_if_not ("PATH", DEFAULT_PATH_VALUE); +-#if 0 + set_auto_export (temp_var); /* XXX */ +-#endif + + temp_var = set_if_not ("TERM", "dumb"); +-#if 0 + set_auto_export (temp_var); /* XXX */ +-#endif + + #if defined (__QNX__) + /* set node id -- don't import it from the environment */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-006.signames.c.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-006.signames.c.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,17 @@ +--- support/signames.c 2008-08-13 08:31:48.000000000 -0400 ++++ support/signames.c 2009-08-15 16:40:01.729682000 -0400 +@@ -212,6 +212,14 @@ + signal_names[SIGXRES] = "SIGXRES"; + #endif + ++#if defined (SIGJVM1) /* Solaris Java Virtual Machine 1 */ ++ signal_names[SIGJVM1] = "SIGJVM1"; ++#endif ++ ++#if defined (SIGJVM2) /* Solaris Java Virtual Machine 2 */ ++ signal_names[SIGJVM2] = "SIGJVM2"; ++#endif ++ + /* HP-UX */ + #if defined (SIGDIL) /* DIL signal (?) */ + signal_names[SIGDIL] = "SIGDIL"; diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-007.rlprivate.h.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-007.rlprivate.h.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,21 @@ +--- lib/readline/rlprivate.h 2009-01-22 21:56:49.000000000 -0500 ++++ lib/readline/rlprivate.h 2009-08-16 10:55:56.178609000 -0400 +@@ -23,6 +23,18 @@ + #if !defined (_RL_PRIVATE_H_) + #define _RL_PRIVATE_H_ + ++#ifdef HAVE_CONFIG_H ++#include ++#endif ++ ++#if defined(HANDLE_MULTIBYTE) ++ ++#include ++#include ++#include ++ ++#endif /* HANDLE_MULTIBYTE */ ++ + #include "rlconf.h" /* for VISIBLE_STATS */ + #include "rlstdc.h" + #include "posixjmp.h" /* defines procenv_t */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-008.xmbsrtowcs.c.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-008.xmbsrtowcs.c.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,11 @@ +--- lib/glob/xmbsrtowcs.c 2008-08-12 10:17:54.000000000 -0400 ++++ lib/glob/xmbsrtowcs.c 2009-08-10 15:46:18.000000000 -0400 +@@ -30,7 +30,7 @@ + #if HANDLE_MULTIBYTE + + #ifndef FREE +-# define FREE(x) do { if (x) free (x); } while (0) ++# define FREE(x) do { if (x) free (x); x = 0; } while (0) + #endif + /* On some locales (ex. ja_JP.sjis), mbsrtowc doesn't convert 0x5c to U<0x5c>. + So, this function is made for converting 0x5c to U<0x5c>. */ diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-009.configure.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-009.configure.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,321 @@ +--- configure 2009-12-29 05:34:51.000000000 -0800 ++++ configure 2010-09-01 10:45:06.225859891 -0700 +@@ -1,4 +1,4 @@ +-#! /bin/sh ++#! /bin/bash + # From configure.in for Bash 4.1, version 4.019. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.63 for bash 4.1-release. +@@ -13,6 +13,8 @@ + ## M4sh Initialization. ## + ## --------------------- ## + ++export LD_OPTIONS="-lc -lm -lgen -lsocket -lnsl -lresolv -z ignore" ++ + # Be more Bourne compatible + DUALCASE=1; export DUALCASE # for MKS sh + if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +@@ -592,7 +594,7 @@ + subdirs= + MFLAGS= + MAKEFLAGS= +-SHELL=${CONFIG_SHELL-/bin/sh} ++SHELL=${CONFIG_SHELL-/bin/bash} + + # Identity of this package. + PACKAGE_NAME='bash' +@@ -3500,7 +3502,7 @@ + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no +- CFLAGS="-g" ++ CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF + /* confdefs.h. */ + _ACEOF +@@ -3579,7 +3581,7 @@ + sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag +- CFLAGS="-g" ++ CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF + /* confdefs.h. */ + _ACEOF +@@ -3638,7 +3640,7 @@ + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else +- CFLAGS="-g" ++ CFLAGS="" + fi + else + if test "$GCC" = yes; then +@@ -5092,7 +5094,7 @@ + + if test -z "$CC_FOR_BUILD"; then + if test "x$cross_compiling" = "xno"; then +- CC_FOR_BUILD='$(CC)' ++ CC_FOR_BUILD='$(CC) $(CPPFLAGS) $(CFLAGS)' + else + CC_FOR_BUILD=gcc + fi +@@ -5100,7 +5102,7 @@ + + + +-test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1 ++test -z "$CFLAGS" && CFLAGS="${CFLAGS}" auto_cflags=1 + + test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O2" + +@@ -5132,7 +5134,7 @@ + LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""} + fi + +-test -z "$CFLAGS_FOR_BUILD" && CFLAGS_FOR_BUILD="-g" ++test -z "$CFLAGS_FOR_BUILD" && CFLAGS_FOR_BUILD="" + + + +@@ -5257,9 +5259,14 @@ + int + main () + { ++#if defined(sun) || defined(__sun) || defined(__sun__) ++#error "we want to use libcurses." ++return 255; ++#else + return tgetent (); + ; + return 0; ++#endif + } + _ACEOF + rm -f conftest.$ac_objext conftest$ac_exeext +@@ -6164,7 +6171,7 @@ + $as_echo_n "(cached) " >&6 + else + cat >conftest.make <<\_ACEOF +-SHELL = /bin/sh ++SHELL = /bin/bash + all: + @echo '@@@%%%=$(MAKE)=@@@%%%' + _ACEOF +@@ -6190,7 +6197,7 @@ + + case "$host_os" in + opennt*|interix*) MAKE_SHELL="$INTERIX_ROOT/bin/sh" ;; +-*) MAKE_SHELL=/bin/sh ;; ++*) MAKE_SHELL=/bin/bash ;; + esac + + +@@ -7177,7 +7184,7 @@ + # Prepare PATH_SEPARATOR. + # The user is always right. + if test "${PATH_SEPARATOR+set}" != set; then +- echo "#! /bin/sh" >conf$$.sh ++ echo "#! /bin/bash" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then +@@ -7191,7 +7198,7 @@ + # Find out how to test for executable files. Don't use a zero-byte file, + # as systems may use methods other than mode bits to determine executability. + cat >conf$$.file <<_ASEOF +-#! /bin/sh ++#! /bin/bash + exit 0 + _ASEOF + chmod +x conf$$.file +@@ -7288,7 +7295,7 @@ + # Prepare PATH_SEPARATOR. + # The user is always right. + if test "${PATH_SEPARATOR+set}" != set; then +- echo "#! /bin/sh" >conf$$.sh ++ echo "#! /bin/bash" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then +@@ -7302,7 +7309,7 @@ + # Find out how to test for executable files. Don't use a zero-byte file, + # as systems may use methods other than mode bits to determine executability. + cat >conf$$.file <<_ASEOF +-#! /bin/sh ++#! /bin/bash + exit 0 + _ASEOF + chmod +x conf$$.file +@@ -7359,7 +7366,7 @@ + # Prepare PATH_SEPARATOR. + # The user is always right. + if test "${PATH_SEPARATOR+set}" != set; then +- echo "#! /bin/sh" >conf$$.sh ++ echo "#! /bin/bash" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then +@@ -7373,7 +7380,7 @@ + # Find out how to test for executable files. Don't use a zero-byte file, + # as systems may use methods other than mode bits to determine executability. + cat >conf$$.file <<_ASEOF +-#! /bin/sh ++#! /bin/bash + exit 0 + _ASEOF + chmod +x conf$$.file +@@ -8992,7 +8999,7 @@ + # Prepare PATH_SEPARATOR. + # The user is always right. + if test "${PATH_SEPARATOR+set}" != set; then +- echo "#! /bin/sh" >conf$$.sh ++ echo "#! /bin/bash" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then +@@ -9102,7 +9109,7 @@ + else + + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ +- ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh ++ ${CONFIG_SHELL-/bin/bash} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done +@@ -13042,39 +13049,18 @@ + /* end confdefs.h. */ + /* Define isinf to an innocuous variant, in case declares isinf. + For example, HP-UX 11i declares gettimeofday. */ +-#define isinf innocuous_isinf +- +-/* System header to define __stub macros and hopefully few prototypes, +- which can conflict with char isinf (); below. +- Prefer to if __STDC__ is defined, since +- exists even on freestanding compilers. */ +- +-#ifdef __STDC__ +-# include +-#else +-# include +-#endif +- +-#undef isinf +- ++#include + /* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +-#ifdef __cplusplus +-extern "C" +-#endif +-char isinf (); + /* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +-#if defined __stub_isinf || defined __stub___isinf +-choke me +-#endif + + int + main () + { +-return isinf (); ++return isinf(0.0); + ; + return 0; + } +@@ -13134,39 +13120,26 @@ + /* end confdefs.h. */ + /* Define isnan to an innocuous variant, in case declares isnan. + For example, HP-UX 11i declares gettimeofday. */ +-#define isnan innocuous_isnan + + /* System header to define __stub macros and hopefully few prototypes, + which can conflict with char isnan (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +-#ifdef __STDC__ +-# include +-#else +-# include +-#endif +- +-#undef isnan ++#include + + /* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +-#ifdef __cplusplus +-extern "C" +-#endif +-char isnan (); ++ + /* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +-#if defined __stub_isnan || defined __stub___isnan +-choke me +-#endif + + int + main () + { +-return isnan (); ++return isnan(0.0); + ; + return 0; + } +@@ -25521,7 +25494,7 @@ + exit 69 + ' >conftest + chmod u+x conftest +-(SHELL=/bin/sh; export SHELL; ./conftest >/dev/null 2>&1) ++(SHELL=/bin/bash; export SHELL; ./conftest >/dev/null 2>&1) + if test $? -ne 69; then + ac_cv_sys_interpreter=yes + else +@@ -30117,9 +30090,14 @@ + int + main () + { ++#if defined(sun) || defined(__sun) || defined(__sun__) ++#error "we want to use libcurses" ++return 255; ++#else + return tgetent (); + ; + return 0; ++#endif + } + _ACEOF + rm -f conftest.$ac_objext conftest$ac_exeext +@@ -30302,7 +30280,7 @@ + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +-LIBS="-lcurses $LIBS" ++LIBS="/usr/lib/libcurses.so.1 $LIBS" + cat >conftest.$ac_ext <<_ACEOF + /* confdefs.h. */ + _ACEOF +@@ -30468,7 +30446,7 @@ + TERMCAP_LIB= + TERMCAP_DEP= + else +-TERMCAP_LIB=-lcurses ++TERMCAP_LIB=/usr/lib/libcurses.so.1 + TERMCAP_DEP= + fi + +@@ -30676,7 +30654,7 @@ + then + { $as_echo "$as_me:$LINENO: checking shared object configuration for loadable builtins" >&5 + $as_echo_n "checking shared object configuration for loadable builtins... " >&6; } +- eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"` ++ eval `${CONFIG_SHELL-/bin/bash} ${srcdir}/support/shobj-conf -C "${CC}" -c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"` + + + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-010.input.c.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-010.input.c.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,13 @@ +--- lib/readline/input.c 2009-04-19 10:12:03.000000000 -0700 ++++ lib/readline/input.c 2010-09-01 10:46:23.386144948 -0700 +@@ -51,6 +51,10 @@ + # include + #endif + ++#if defined(SOLARIS) ++# include ++#endif ++ + #include + #include + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-011.input_avail.c.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-011.input_avail.c.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,13 @@ +--- lib/sh/input_avail.c 2009-04-19 10:01:14.000000000 -0700 ++++ lib/sh/input_avail.c 2010-09-01 10:47:30.418016819 -0700 +@@ -45,6 +45,10 @@ + # include + #endif + ++#if defined(SOLARIS) ++# include /* Solaris FIONREAD */ ++#endif ++ + #include + #include + diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-012.rlconf.h.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-012.rlconf.h.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,11 @@ +--- lib/readline/rlconf.h 2009-01-04 11:32:33.000000000 -0800 ++++ lib/readline/rlconf.h 2010-09-01 10:48:13.018894232 -0700 +@@ -39,7 +39,7 @@ + #define DEFAULT_INPUTRC "~/.inputrc" + + /* The ultimate last-ditch filenname for an init file -- system-wide. */ +-#define SYS_INPUTRC "/etc/inputrc" ++#define SYS_INPUTRC "/etc/bash/inputrc" + + /* If defined, expand tabs to spaces. */ + #define DISPLAY_TABS diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-013.bashref.info.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-013.bashref.info.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,22 @@ +--- doc/bashref.info 2009-12-29 12:59:33.000000000 -0800 ++++ doc/bashref.info 2010-09-01 10:49:49.070499702 -0700 +@@ -6387,7 +6387,7 @@ + directory. The name of this file is taken from the value of the shell + variable `INPUTRC'. If that variable is unset, the default is + `~/.inputrc'. If that file does not exist or cannot be read, the +-ultimate default is `/etc/inputrc'. ++ultimate default is `/etc/bash/inputrc'. + + When a program which uses the Readline library starts up, the init + file is read, and the key bindings are set. +@@ -6812,8 +6812,8 @@ + `$include' + This directive takes a single filename as an argument and reads + commands and bindings from that file. For example, the following +- directive reads from `/etc/inputrc': +- $include /etc/inputrc ++ directive reads from `/etc/bash/inputrc': ++ $include /etc/bash/inputrc + +  + File: bashref.info, Node: Sample Init File, Prev: Conditional Init Constructs, Up: Readline Init File diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-014.bash.man.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-014.bash.man.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,16 @@ +--- doc/bash.1 2009-12-30 10:01:31.000000000 -0800 ++++ doc/bash.1 2010-09-01 10:50:49.912191287 -0700 +@@ -5235,11 +5235,11 @@ + .IP \fB$include\fP + This directive takes a single filename as an argument and reads commands + and bindings from that file. For example, the following directive +-would read \fI/etc/inputrc\fP: ++would read \fI/etc/bash/inputrc\fP: + .sp 1 + .RS + .nf +-\fB$include\fP \^ \fI/etc/inputrc\fP ++\fB$include\fP \^ \fI/etc/bash/inputrc\fP + .fi + .RE + .SS Searching diff -r 07cc6a1a08ad -r 77641682ba6f components/bash/solaris-015.rbash.man.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/bash/solaris-015.rbash.man.patch Sat Feb 26 10:03:27 2011 -0800 @@ -0,0 +1,13 @@ +--- doc/rbash.1 2008-08-12 06:24:51.000000000 -0700 ++++ doc/rbash.1 2010-09-01 10:52:04.397206373 -0700 +@@ -1,8 +1,8 @@ +-.TH RBASH 1 "2004 Apr 20" "GNU Bash-4.0" ++.TH RBASH 1 "2004 Apr 20" "GNU Bash-4.1" + .SH NAME + rbash \- restricted bash, see \fBbash\fR(1) + .SH RESTRICTED SHELL + .nr zY 1 +-.so bash.1 ++.so /usr/share/man/man1/bash.1 + .SH SEE ALSO + bash(1)