Browse Source

changed zdump to avoid printing empty vars/arrs/maps

Jaromil 3 years ago
parent
commit
c31c68556a
1 changed files with 12 additions and 4 deletions
  1. 12 4
      zuper

+ 12 - 4
zuper

@@ -190,25 +190,33 @@ function ckreq reqck() {
190 190
     return $err
191 191
 }
192 192
 
193
+# dump all variables, arrays and maps declared as global in zuper
194
+# do not print out what is empty
193 195
 zdump() {
194 196
     fn zdump
195 197
     [[ ${#vars} -gt 0 ]] && {
196 198
         print "Global variables:"
197 199
         for _v in $vars; do
198
-            print " $_v = \t ${(P)_v}"
200
+			_c=${(P)_v}
201
+			[[ "$_c" = "" ]] ||
202
+				print " $_v = \t $_c"
199 203
         done
200 204
     }
201 205
     [[ ${#arrs} -gt 0 ]] && {
202 206
         print "Global arrays:"
203 207
         for _a in $arrs; do
204
-        print " $_a \t ( ${(P)_a} )"
208
+			_c=${(P)_a}
209
+			[[ "$_c" = "" ]] ||
210
+				print " $_a \t ( ${(P)_a} )"
205 211
         done
206 212
     }
207 213
     [[ ${#maps} -gt 0 ]] && {
208 214
         print "Global maps:"
209 215
         for _m in $maps; do
210
-            print " $_m [key] \t ( ${(Pk)_m} )"
211
-            print " $_m [val] \t ( ${(Pv)_m} )"
216
+			[[ "${(Pv)_m}" = "" ]] || {
217
+				print " $_m [key] \t ( ${(Pk)_m} )"
218
+				print " $_m [val] \t ( ${(Pv)_m} )"
219
+			}
212 220
         done
213 221
     }
214 222
 }