summaryrefslogtreecommitdiff
path: root/sys-cluster/glusterfs/files/glusterfs-11.0-extras-defer-invoking-of-gluster-volume-set-help-as-.patch
blob: f3eacb3a823dafa796327a46c3f9f9507fce05e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From 26126dd1467fc40af372b9f2ba6ab167e5b9f309 Mon Sep 17 00:00:00 2001
From: Jaco Kroon <jaco@uls.co.za>
Date: Mon, 28 Aug 2023 09:54:47 +0200
Subject: [PATCH] extras: defer invoking of gluster volume set help as late as
 we can.

---
 extras/command-completion/gluster.bash | 44 +++++++++++++++++++-------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/extras/command-completion/gluster.bash b/extras/command-completion/gluster.bash
index 70f8e19558..a096b62890 100644
--- a/extras/command-completion/gluster.bash
+++ b/extras/command-completion/gluster.bash
@@ -1,15 +1,5 @@
 #!/bin/bash
 
-if pidof glusterd > /dev/null 2>&1; then
-        GLUSTER_SET_OPTIONS="
-        $(for token in `gluster volume set help 2>/dev/null | grep "^Option:" | cut -d ' ' -f 2`
-        do
-                echo "{$token},"
-        done)
-        "
-        GLUSTER_RESET_OPTIONS="$GLUSTER_SET_OPTIONS"
-fi
-
 GLUSTER_TOP_SUBOPTIONS1="
         {nfs},
         {brick},
@@ -161,12 +151,14 @@ GLUSTER_VOLUME_OPTIONS="
                 },
                 {reset
                         {__VOLNAME
-                                [ $GLUSTER_RESET_OPTIONS ]
+                                {__VOLOPTIONS
+                                },
                         }
                 },
                 {set
                         {__VOLNAME
-                                [ $GLUSTER_SET_OPTIONS ]
+                                {__VOLOPTIONS
+                                },
                         }
                 },
                 {start
@@ -280,6 +272,34 @@ __VOLNAME ()
         return 0
 }
 
+__VOLOPTIONS()
+{
+        local zero=0
+        local ret=0
+        local cur_word="$2"
+        local list=""
+
+        if [ "X$1" == "X" ]; then
+                return
+
+        elif [ "$1" == "match" ]; then
+                return 0
+
+        elif [ "$1" == "complete" ]; then
+                if ! pidof glusterd > /dev/null 2>&1; then
+                        list='';
+                else
+                        list=`gluster volume set help 2>/dev/null | grep "^Option:" | cut -d ' ' -f 2`
+                fi
+        else
+                return 0
+        fi
+
+        func_return=`echo $(compgen -W "$list" -- $cur_word)`
+
+        return 0
+}
+
 _gluster_throw () {
 #echo $1 >&2
         COMPREPLY=''
-- 
2.41.0