libstd.bash: function to check Bash variable type added

This commit is contained in:
2021-05-07 15:51:28 +02:00
parent a6623727ae
commit 183e7f40a2
+27
View File
@@ -244,6 +244,33 @@ std::get_os_release() {
${func_map[${OS}]}
}
std::get_type() {
local -a signature=$(typeset -p "$1")
case ${signature[1]} in
-Ai* )
echo 'int dict'
;;
-A* )
echo 'dict'
;;
-ai* )
echo 'int array'
;;
-a* )
echo 'array'
;;
-i* )
echo 'integer'
;;
-- )
echo 'string'
;;
* )
echo 'none'
return 1
esac
}
# Local Variables:
# mode: sh
# sh-basic-offset: 8