]> git.pld-linux.org Git - packages/bash-completion.git/commitdiff
builder-completion: try to parse .spec from commandline
authorElan Ruusamäe <glen@delfi.ee>
Sun, 12 Aug 2012 18:15:23 +0000 (21:15 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Sun, 12 Aug 2012 18:15:23 +0000 (21:15 +0300)
builder.bash-completion

index eb80e883851a802bbed8ef8f1c229bca12e74d07..da7f04c1ed792aa2847ec86f3c3ed2585868c8aa 100644 (file)
@@ -1,5 +1,21 @@
 # PLD Linux builder(1) script completion
 
+# get active spec file from commandline
+# caller should make $spec local variable
+# TODO: it gets it wrong if some option arg is found before spec itself
+_builder_get_spec()
+{
+       local i
+       spec=
+       for (( i=1; i < ${#words[@]}-1; i++ )); do
+               if [[ ${words[i]} != -* ]]; then
+                       spec=${words[i]}
+                       break
+               fi
+       done
+       [[ ! -f $spec ]] && return 0
+}
+
 _builder()
 {
        local cur prev words cword
@@ -7,12 +23,14 @@ _builder()
 
        case $prev in
        -r)
-               local spec=*.spec
+               local spec
+               _builder_get_spec
                COMPREPLY=( $( compgen -W '$( git tag )' -- "$cur" ) )
                return 0
                ;;
        --with|--without)
-               local spec=*.spec
+               local spec
+               _builder_get_spec
                $1 -nn -ncs --show-avail-bconds $spec
                return 0
                ;;
This page took 0.039446 seconds and 4 git commands to generate.