Check for overflow when allocating RcBox
[glib.git] / gio / completion / gresource
blobef1145d62aa84d00ebeb1485275c31e2b1d37a08
2 # Check for bash
3 [ -z "$BASH_VERSION" ] && return
5 ####################################################################################################
7 __gresource() {
8   local choices coffset section
10   if [ ${COMP_CWORD} -gt 2 ]; then
11       if [ ${COMP_WORDS[1]} = --section ]; then
12           section=${COMP_WORDS[2]}
13           coffset=2
14       else
15           coffset=0
16       fi
17   else
18       coffset=0
19   fi
21   case "$((${COMP_CWORD}-$coffset))" in
22     1)
23       choices=$'--section \nhelp \nsections \nlist \ndetails \nextract '
24       ;;
26     2)
27       case "${COMP_WORDS[$(($coffset+1))]}" in
28         --section)
29           return 0
30           ;;
32         help)
33           choices=$'sections\nlist\ndetails\nextract'
34           ;;
36         sections|list|details|extract)
37           COMPREPLY=($(compgen -f -- ${COMP_WORDS[${COMP_CWORD}]}))
38           return 0
39           ;;
40       esac
41       ;;
43     3)
44       case "${COMP_WORDS[$(($coffset+1))]}" in
45         list|details|extract)
46           choices="$(gresource list ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null | sed -e 's.$. .')"
47           ;;
48       esac
49       ;;
50   esac
52   local IFS=$'\n'
53   COMPREPLY=($(compgen -W "${choices}" -- "${COMP_WORDS[${COMP_CWORD}]}"))
56 ####################################################################################################
58 complete -o nospace -F __gresource gresource