tools/gstreamer-completion: Allow 1.0 and 0.10 scripts installed simultaneously

As long as the scripts' filenames are different, and the _gst_inspect
and _gst_launch functions are named differently, the completion scripts
for GStreamer 1.0 and 0.10 can be installed side-by-side in
/etc/bash_completion.d.

On my 0.10 branch† the completion script is renamed to
"gstreamer-completion-0.10" and the functions are renamed to
"_gst_inspect_0_10" and "_gst_launch_0_10". The remaining helper
functions should remain identical (the command-line interface to
gst-inspect hasn't changed, nor has the format of the gst-launch
pipeline), so it doesn't matter if the 1.0 script overrides the 0.10
script's definitions.

Note that I don't expect there to be another GStreamer 0.10 release, so
the 0.10 completion script will probably never be officially released;
but it is still worthwhile allowing both scripts to be installed
alongside each other, for those who install the 0.10 completion script
manually.

Fixes: #690515https://github.com/drothlis/gstreamer/blob/bash-completion-0.10/tools/gstreamer-completion-0.10
This commit is contained in:
David Rothlisberger 2012-12-26 11:54:51 +00:00 committed by Stefan Sauer
parent 5d6635f9b4
commit 9f5e9c8632

View file

@ -1,9 +1,8 @@
# Bash tab-completion for GStreamer. -*- shell-script -*-
# Put this in /etc/bash_completion.d/
_gst_version=1.0
_gst_inspect() {
local _gst_version=1.0
local cur cword prev words
_gst_init_completion
[[ "$cur" == "=" ]] && cur=
@ -17,9 +16,10 @@ _gst_inspect() {
-- "$cur") )
[[ $COMPREPLY == *= ]] && compopt -o nospace 2>/dev/null
} &&
complete -F _gst_inspect gst-inspect-$_gst_version
complete -F _gst_inspect gst-inspect-1.0
_gst_launch() {
local _gst_version=1.0
local cur cword prev words
_gst_init_completion
local curtype option element property
@ -29,7 +29,7 @@ _gst_launch() {
COMPREPLY=( $(_gst_launch_compgen) )
[[ $COMPREPLY == *= ]] && compopt -o nospace 2>/dev/null
} &&
complete -o default -F _gst_launch gst-launch-$_gst_version
complete -o default -F _gst_launch gst-launch-1.0
_gst_common_options() {
if [[ -n "$curtype" ]]; then # Called from _gst_launch