I have a function myFunction() that shall take an integer variable from outside, print it and then increment it.
This works:
myFunction:
myFunction() {
local var="${1}"
eval "printf '%s\n' \$$var"
eval "$var=$(($var+1))"
}
But, I don't want to use eval in this as a user of this function might enter a wrong variable name that might then be executed. I would like to use something like printf -v as it would make the usage safer.
How can I do this?