File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 84
84
echo "No such key: $key"
85
85
fi
86
86
87
- # Example of how to assign the config value to a variable:
88
- # result=$(config_get "${args[key]}")
89
- # echo $result
87
+ # Or, assign a default value if value not found
88
+ config_get "$key" "the default value"
89
+
90
+ # Or, assign the result to a variable
91
+ result=$(config_get "$key")
92
+ echo "$result"
90
93
91
94
92
95
` ` `
@@ -162,6 +165,8 @@ saved: bashly = works
162
165
163
166
` ` ` shell
164
167
world
168
+ world
169
+ world
165
170
166
171
167
172
` ` `
@@ -170,6 +175,8 @@ world
170
175
171
176
` ` ` shell
172
177
No such key: invalid_key
178
+ the default value
179
+
173
180
174
181
175
182
` ` `
Original file line number Diff line number Diff line change @@ -12,5 +12,5 @@ config_get "$key" "the default value"
12
12
13
13
# Or, assign the result to a variable
14
14
result=$( config_get " $key " )
15
- echo $result
15
+ echo " $result "
16
16
You can’t perform that action at this time.
0 commit comments