Is there any way to print all the variables declared and used within a Bash script?
For example printf "%s\n" "${FUNCNAME[@]}"
will print the names of all shell functions currently in the execution call stack.
Ex: This is my script content (there must be a lot of declared variables):
#!/bin/bash
say_hello() {
name="$1"
echo "Hello $name"
}
my_name="Luis Daniel"
my_age="29"
say_hello "$my_name"
Then, I need to log something like this:
my_name = Luis Daniel
my_age = 29
name = Luis Daniel