[Bash-completion-devel] some patches
Raphaël
raphael.droz at gmail.com
Sat Jun 11 21:43:15 UTC 2011
On Sat, Jun 11, 2011 at 10:32:17PM +0200, David Paleino wrote:
> On Sat, 11 Jun 2011 21:54:35 +0200, Raphaël wrote:
>
> > So... you'll find:
>
> Better, but I would've liked the brand-new completions to be posted as git
> commits too :)
>
> (also, those patches aren't handled by "git am", something wrong must've
> happened. I work-arounded it with git apply+git commit)
I will be more careful about this the next time.
[edit, I wasn't, see below]
> > - a completion specific to the mysql client.
>
> Added, with some minor modifications (in a couple of lines you used tabs
> instead of four spaces), and with the usage of _parse_help instead of
> hardcoding the options list.
I didn't use it because of:
diff \
<(mysql --help|grep -woE -- '--[a-z0-9-]+'|sort -u|grep -v 'variable-name') \
<(_parse_help mysql|sort -u|sed s/=//)
>
> > - a completion for the boinc client derived from upstream's wiki.
>
> Uhm. The Debian package (boinc-client) installs it, and the source for 6.12.28
> ships it too (I haven't checked the last one, but I suppose they didn't drop
> it -- why would they?). I think other distributions install it as well.
>
> I suggest you send this completion upstream to BOINC :), specifying the minimum
> required version of bash-completion (maybe just a comment at the top of the
> file is ok).
I didn't noticed that (using gentoo these months), I'll send it to the
boinc devs.
> > - the patch previously mentioned about mplayer, options list and i18n
>
> I'm not entirely sure about this. I don't understand why LC_LANG can't be
> used -- but usually "LANG=C command" works everywhere. If it works, I'd prefer
> this way, since otherwise we should hardcode every language mplayer is/will be
> translated to :)
I looked at the $(strings mplayer). English strings appears but it seems
to be only the untranslated strings.
The 'Name.*Min Max' string IS translated. It confirms what says
mplayer's ./configure:
--language=lang default language to use [en]
(The LINGUAS environment variable is honored).
Should we ask mplayer devs to put a hint character to help parsing ?
or use sed 1,3d ? :)
>
> > - a patch for sitecopy which avoids a failure with grep in some case
> > - a patch which adds lpr(1) and lpq(1) to the cups tools completions
>
> Both applied.
thx
I also forgot it above, I attached a completion for wget(1).
This is a raw file (again) because the last change on it was mixed with
others (its bad) + I changed part of its content in same commit I
renamed it.
I don't want to spend "yet another night in git help *", I already tried
a lot -M X% -B trickery of git format-patch without success.
[ sorry for the git hassle ]
Raph
-------------- next part --------------
# wget(1) completion for bash 4
# Raphaël Droz <raphael.droz+floss at gmail.com>
# License: GNU GPL v2 or later
# $Id: wget,v 0.5 2011/11/06 23:18:16 drzraf Exp $
have wget || return
_wget() {
COMPREPLY=()
local cur prev
_get_comp_words_by_ref -n = cur prev
# If `cur' is long option containing `=', reassign prev and cur
# because we used _get_comp_words_by_ref -n
# it allows both form of long option ('=' and ' ')
# if [[ "$cur" == --*=* ]]; then
# prev=${cur/=*}
# cur=${cur/*=}
# fi
# TODO: test this instead of the above
_split_longopt
case "$prev" in
--progress)
COMPREPLY=( $( compgen -W 'bar dot' -- $cur ) )
return 0
;;
-D|-@(bind-address|@(exclude-|)domains))
_known_hosts_real
return 0
;;
--restrict-file-names)
local excludes
[[ "${cur}" =~ (unix|windows), ]] && excludes="|windows|unix"
[[ "${cur}" =~ (low|upp)ercase, ]] && excludes+="|lowercase|uppercase"
[[ "${cur}" =~ nocontrol ]] && excludes+="|nocontrol"
[[ "${cur}" =~ ascii ]] && excludes+="|ascii"
local lastopt=${cur/*,}
# non-workaround 1
# [[ ! "$COMP_WORDBREAKS =~ , ]] && WORDBREAKS=${COMP_WORDBREAKS},
# COMP_WORDBREAKS=${WORDBREAKS} COMPREPLY=( $( compgen -X "@(${excludes/|})" -W 'unix windows nocontrol ascii lowercase uppercase' -- $lastopt ) )
# workaround 2
local prevopt=
[[ "${cur}" =~ , ]] && prevopt=${cur%,*}
# prevopt is the previous options string used as a prefix
# to avoid COMPREPLY replacing them with the $lastopt completion
[ -n "$prevopt" ] && prevopt+=,
compopt -o nospace
COMPREPLY=( $( compgen -S ',' -P "${prevopt}" -X "@(${excludes/|})" -W 'unix windows nocontrol ascii lowercase uppercase' -- $lastopt ) )
# trying here to make the last option append a space (no more comma-separated option available)
#[[ ${#COMPREPLY[@]} -eq 0 ]] && {
# compopt +o nospace
# COMPREPLY=( $( compgen -P "${prevopt}" -X "@(${excludes/|})" -W 'unix windows nocontrol ascii lowercase uppercase' -- $lastopt ) )
#}
return 0
;;
--prefer-family)
COMPREPLY=( $( compgen -W 'IPv4 IPv6 none' -- $cur ) )
return 0
;;
-P|--directory-prefix|--ca-directory)
# check if the line below is needed (should not)
# compopt -o filenames
_filedir -d
return 0
;;
-a|--load-cookies|--save-cookies|--post-file|--@(ca-|)certificate|--private-key|--random-file|--egd-file|--append-output|--default-page)
_filedir
return 0
;;
-i|--input-file)
_filedir && COMPREPLY=( "${COMPREPLY[@]}" - )
return 0
;;
--secure-protocol)
COMPREPLY=( $( compgen -W 'auto SSLv2 SSLv3 TLSv1' -- $cur ) )
return 0
;;
--@(certificate|private-key)-type)
COMPREPLY=( $( compgen -W 'PEM DER' -- $cur ) )
return 0
;;
--@(follow|ignore)-tags)
COMPREPLY=( $( compgen -W 'a abbr acronym address applet area b base basefont bdo big blockquote \
body br button caption center cite code col colgroup dd del dir div dfn dl dt em fieldset \
font form frame frameset h6 head hr html i iframe img input ins isindex kbd label legend \
li link map menu meta noframes noscript object ol optgroup option p param pre q s samp \
script select small span strike strong style sub sup table tbody td textarea tfoot th \
thead title tr tt u ul var xmp' -- $cur ) )
return 0
;;
--tries|--@(dns-|connect-|)timeout|--limit-rate|--wait|--waitretry|--cut-dirs|--max-redirect)
COMPREPLY=( $( compgen -W "{0..9}" -- $cur ) )
return 0
;;
--quota)
COMPREPLY=( $( compgen -W "{0..9}{k,m}" -- $cur ) )
return 0
;;
--@(http-|proxy-|ftp-|)user)
COMPREPLY=( $( compgen -W "$(sed -n '/^login/s/^[[:blank:]]*login[[:blank:]]//p' ~/.netrc)" -- $cur ) )
return 0
;;
--level)
COMPREPLY=( $( compgen -W "{1..5}" -- $cur ) )
return 0
;;
--header)
COMPREPLY=( $( compgen -W 'Accept Accept-Charset Accept-Encoding Accept-Language \
Accept-Ranges Age Allow Authorization Cache-Control Connection Content-Encoding \
Content-Language Content-Length Content-Location Content-MD5 Content-Range \
Content-Type Date ETag Expect Expires From Host If-Match If-Modified-Since \
If-None-Match If-Range If-Unmodified-Since Last-Modified Location Max-Forwards \
Pragma Proxy-Authenticate Proxy-Authorization Range Referer Retry-After \
Server TE Trailer Transfer-Encoding Upgrade User-Agent Vary Via Warning \
WWW-Authenticate' -- $cur ) )
return 0
;;
esac
case "$cur" in
--*)
_longopt wget
return 0
;;
# choose this behavior
-)
compopt -o nospace
COMPREPLY=( -- )
return 0
;;
# or this one (every short option has a long equivalent)
-*)
COMPREPLY=( $( compgen -W "$(wget -h | sed -n 's/^[ [:blank:]]*\(-[a-zA-A46]\).*$/\1/p')" -- $cur ) )
return 0
;;
*)
compopt -o nospace
# option 1 :
# cur=`_get_cword :`
# COMPREPLY=( $( compgen -W "http{,s}://{,www.} ftp://" -- $cur ) )
# option 2 (TODO: not the long-term solution):
# see: https://lists.gnu.org/archive/html/bug-bash/2011-06/msg00032.html
export COMP_WORDBREAKS=${COMP_WORDBREAKS//:/}
COMPREPLY=( $( compgen -W "http{,s}://{,www.} ftp://" -- $cur ) )
return 0
;;
esac
return 0
}
complete -F _wget wget
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20110611/00509dd9/attachment-0001.pgp>
More information about the Bash-completion-devel
mailing list