[Pkg-libvirt-commits] [libguestfs] 12/384: bash: execute --long-options only when needed

Hilko Bengen bengen at moszumanska.debian.org
Sun Mar 29 16:54:54 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit 4b792354f068b80a01782f85b71a471e3aa6f031
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Tue Nov 25 18:15:37 2014 +0100

    bash: execute --long-options only when needed
    
    Delay the execution of $tool --long-options only when really using its
    output.
---
 bash/guestfish           |  3 +--
 bash/guestmount          |  3 +--
 bash/virt-alignment-scan | 23 ++++++++++++-----------
 bash/virt-rescue         |  3 +--
 bash/virt-resize         |  9 +++++----
 5 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/bash/guestfish b/bash/guestfish
index 513fbe2..46d7847 100644
--- a/bash/guestfish
+++ b/bash/guestfish
@@ -35,8 +35,6 @@ _guestfish ()
 
     _init_completion -s || return
 
-    longopts="$(guestfish --long-options)"
-
     # See if user has specified certain options anywhere on the
     # command line before the current word.
     while [ $c -lt $COMP_CWORD ]; do
@@ -60,6 +58,7 @@ _guestfish ()
     case "$cur" in
         --*)
             # --options
+            longopts="$(guestfish --long-options)"
             COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
             return ;;
         *)
diff --git a/bash/guestmount b/bash/guestmount
index 9d91f7a..db79521 100644
--- a/bash/guestmount
+++ b/bash/guestmount
@@ -35,8 +35,6 @@ _guestmount ()
 
     _init_completion -s || return
 
-    longopts="$(guestmount --long-options)"
-
     # See if user has specified certain options anywhere on the
     # command line before the current word.
     while [ $c -lt $COMP_CWORD ]; do
@@ -57,6 +55,7 @@ _guestmount ()
     case "$cur" in
         --*)
             # --options
+            longopts="$(guestmount --long-options)"
             COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
             return ;;
         *)
diff --git a/bash/virt-alignment-scan b/bash/virt-alignment-scan
index 3c77baf..cef8365 100644
--- a/bash/virt-alignment-scan
+++ b/bash/virt-alignment-scan
@@ -31,7 +31,7 @@ _guestfs_virsh_list ()
 _guestfs_virttools ()
 {
     local cur prev words cword split
-    local longopts="$1" flag_ro="$2" doms
+    local longopts tool="$1" flag_ro="$2" doms
 
     _init_completion -s || return
 
@@ -45,6 +45,7 @@ _guestfs_virttools ()
     case "$cur" in
         --*)
             # --options
+            longopts="$($tool --long-options)"
             COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
             return ;;
         *)
@@ -55,60 +56,60 @@ _guestfs_virttools ()
 
 _virt_alignment_scan ()
 {
-    _guestfs_virttools "$(virt-alignment-scan --long-options)" 1
+    _guestfs_virttools "virt-alignment-scan" 1
 } &&
 complete -o default -F _virt_alignment_scan virt-alignment-scan
 
 _virt_cat ()
 {
-    _guestfs_virttools "$(virt-cat --long-options)" 1
+    _guestfs_virttools "virt-cat" 1
 } &&
 complete -o default -F _virt_cat virt-cat
 
 _virt_df ()
 {
-    _guestfs_virttools "$(virt-df --long-options)" 1
+    _guestfs_virttools "virt-df" 1
 } &&
 complete -o default -F _virt_df virt-df
 
 _virt_edit ()
 {
-    _guestfs_virttools "$(virt-edit --long-options)" 0
+    _guestfs_virttools "virt-edit" 0
 } &&
 complete -o default -F _virt_edit virt-edit
 
 _virt_filesystems ()
 {
-    _guestfs_virttools "$(virt-filesystems --long-options)" 1
+    _guestfs_virttools "virt-filesystems" 1
 } &&
 complete -o default -F _virt_filesystems virt-filesystems
 
 _virt_format ()
 {
-    _guestfs_virttools "$(virt-format --long-options)" 0
+    _guestfs_virttools "virt-format" 0
 } &&
 complete -o default -F _virt_format virt-format
 
 _virt_inspector ()
 {
-    _guestfs_virttools "$(virt-inspector --long-options)" 1
+    _guestfs_virttools "virt-inspector" 1
 } &&
 complete -o default -F _virt_inspector virt-inspector
 
 _virt_ls ()
 {
-    _guestfs_virttools "$(virt-ls --long-options)" 1
+    _guestfs_virttools "virt-ls" 1
 } &&
 complete -o default -F _virt_ls virt-ls
 
 _virt_sysprep ()
 {
-    _guestfs_virttools "$(virt-sysprep --long-options)" 0
+    _guestfs_virttools "virt-sysprep" 0
 } &&
 complete -o default -F _virt_sysprep virt-sysprep
 
 _virt_log ()
 {
-    _guestfs_virttools "$(virt-log --long-options)" 1
+    _guestfs_virttools "virt-log" 1
 } &&
 complete -o default -F _virt_log virt-log
diff --git a/bash/virt-rescue b/bash/virt-rescue
index 7987bb3..bb9ca6d 100644
--- a/bash/virt-rescue
+++ b/bash/virt-rescue
@@ -35,8 +35,6 @@ _virt_rescue ()
 
     _init_completion -s || return
 
-    longopts="$(virt-rescue --long-options)"
-
     # See if user has specified certain options anywhere on the
     # command line before the current word.
     while [ $c -lt $COMP_CWORD ]; do
@@ -57,6 +55,7 @@ _virt_rescue ()
     case "$cur" in
         --*)
             # --options
+            longopts="$(virt-rescue --long-options)"
             COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
             return ;;
         *)
diff --git a/bash/virt-resize b/bash/virt-resize
index 39ef982..d5ac2f5 100644
--- a/bash/virt-resize
+++ b/bash/virt-resize
@@ -19,13 +19,14 @@
 _guestfs_options_only ()
 {
     local cur prev words cword split
-    local longopts="$1"
+    local longopts tool="$1"
 
     _init_completion -s || return
 
     case "$cur" in
         --*)
             # --options
+            longopts="$($tool --long-options)"
             COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
             return ;;
         *)
@@ -36,18 +37,18 @@ _guestfs_options_only ()
 
 _virt_builder ()
 {
-    _guestfs_options_only "$(virt-builder --long-options)"
+    _guestfs_options_only "virt-builder"
 } &&
 complete -o default -F _virt_builder virt-builder
 
 _virt_resize ()
 {
-    _guestfs_options_only "$(virt-resize --long-options)"
+    _guestfs_options_only "virt-resize"
 } &&
 complete -o default -F _virt_resize virt-resize
 
 _virt_sparsify ()
 {
-    _guestfs_options_only "$(virt-sparsify --long-options)"
+    _guestfs_options_only "virt-sparsify"
 } &&
 complete -o default -F _virt_sparsify virt-sparsify

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list