Browse Source

Use declare builtin to show variables in debug_var()

Alois Mahdal 6 years ago
parent
commit
488925f642
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      src/include/mkit.sh

+ 4
- 4
src/include/mkit.sh View File

66
     #
66
     #
67
     $MKIT_DEBUG || return 0
67
     $MKIT_DEBUG || return 0
68
     local __mkit_debug_var_name__       # variable name to debug
68
     local __mkit_debug_var_name__       # variable name to debug
69
+    local decl                          # declare string
69
     for __mkit_debug_var_name__ in "$@"; do
70
     for __mkit_debug_var_name__ in "$@"; do
70
         {
71
         {
71
-            echo -n "MKIT_DEBUG: ${FUNCNAME[1]}():"
72
-            echo -n " $__mkit_debug_var_name__"
73
-            echo -n "='${!__mkit_debug_var_name__}'"
74
-            echo
72
+            decl=$(declare -p "$__mkit_debug_var_name__")
73
+            decl=${decl#declare ?? }
74
+            echo "MKIT_DEBUG: ${FUNCNAME[1]}(): $decl"
75
         } >&2
75
         } >&2
76
     done
76
     done
77
 }
77
 }