summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Zullinger <tmz@pobox.com>2010-09-10 16:22:01 -0400
committerJesse Keating <jkeating@redhat.com>2010-09-10 18:41:38 -0700
commite2a8d7261cec8cd5a431b0ece8766cf5e5ba7b85 (patch)
tree478caec2e24d7dc4457d20a0651cb3202937040f
parent76272ddc502454f95d2f2a54f038971476366bc1 (diff)
downloadfedora-packager-e2a8d7261cec8cd5a431b0ece8766cf5e5ba7b85.zip
fedora-packager-e2a8d7261cec8cd5a431b0ece8766cf5e5ba7b85.tar.gz
fedora-packager-e2a8d7261cec8cd5a431b0ece8766cf5e5ba7b85.tar.xz
fedpkg: Use _filedir for path completion
The _filedir function is a bit more robust than using compgen directly. A wrapper function is used to filter out .git directories from results.
-rw-r--r--src/fedpkg.bash27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/fedpkg.bash b/src/fedpkg.bash
index 8ea8a66..d2279cc 100644
--- a/src/fedpkg.bash
+++ b/src/fedpkg.bash
@@ -14,6 +14,14 @@ _fedpkg()
return 1
}
+ _filedir_exclude_paths()
+ {
+ _filedir "$@"
+ for ((i=0; i<=${#COMPREPLY[@]}; i++)); do
+ [[ ${COMPREPLY[$i]} =~ /?\.git/? ]] && unset COMPREPLY[$i]
+ done
+ }
+
local cur prev
# _get_comp_words_by_ref is in bash-completion >= 1.2, which EL-5 lacks.
if type _get_comp_words_by_ref &>/dev/null; then
@@ -23,9 +31,6 @@ _fedpkg()
prev="${COMP_WORDS[COMP_CWORD-1]}"
fi
-
- local paths_exclude="@(.git|*/.git)"
-
# global options
local options="-h --help -v -q"
@@ -64,7 +69,7 @@ _fedpkg()
--user|-u)
;;
--path)
- COMPREPLY=( $(compgen -d -X "$paths_exclude" -- "$cur") )
+ _filedir_exclude_paths
;;
*)
COMPREPLY=( $(compgen -W "$options $options_value $commands" -- "$cur") )
@@ -150,7 +155,7 @@ _fedpkg()
after="branch"
;;
upload|new-sources)
- after="files"
+ after="file"
after_more=true
;;
esac
@@ -187,16 +192,16 @@ _fedpkg()
COMPREPLY=( $(compgen -W "$(_fedpkg_arch) $all_options" -- "$cur") )
elif [[ -n $options_srpm ]] && in_array "$prev" "$options_srpm"; then
- COMPREPLY=( $(compgen -f -o plusdirs -X "!*.src.rpm" -- "$cur") )
+ _filedir_exclude_paths "*.src.rpm"
elif [[ -n $options_branch ]] && in_array "$prev" "$options_branch"; then
COMPREPLY=( $(compgen -W "$(_fedpkg_branch "$path")" -- "$cur") )
elif [[ -n $options_file ]] && in_array "$prev" "$options_file"; then
- COMPREPLY=( $(compgen -f -o plusdirs -X "$paths_exclude" -- "$cur") )
+ _filedir_exclude_paths
elif [[ -n $options_dir ]] && in_array "$prev" "$options_dir"; then
- COMPREPLY=( $(compgen -d -X "$paths_exclude" -- "$cur") )
+ _filedir_exclude_paths -d
elif [[ -n $options_string ]] && in_array "$prev" "$options_string"; then
COMPREPLY=( )
@@ -207,14 +212,14 @@ _fedpkg()
if [[ $after_counter -eq 0 ]] || [[ $after_more = true ]]; then
case $after in
- file) compgen_extra="-o plusdirs -f -X $paths_exclude" ;;
- srpm) compgen_extra='-o plusdirs -f -X !*.src.rpm' ;;
+ file) _filedir_exclude_paths; compgen_extra=${COMPREPLY[@]} ;;
+ srpm) _filedir_exclude_paths "*.src.rpm"; compgen_extra=${COMPREPLY[@]} ;;
branch) after_options="$(_fedpkg_branch "$path")" ;;
package) after_options="$(_fedpkg_package "$cur")";;
esac
fi
- COMPREPLY=( $(compgen -W "$all_options $all_options_value $after_options" $compgen_extra -- "$cur" ) )
+ COMPREPLY=( $(compgen -W "$all_options $all_options_value $after_options $compgen_extra" -- "$cur" ) )
fi
return 0