With this function:
repr() {
declare -p $1 | cut -d '=' -f 2- > /tmp/.repr
$1=$(</tmp/.repr)
rm /tmp/.repr
}
It gives an error message, when I write:
repr test
This see the argument as string:
repr() {
declare -p 'test' | cut -d '=' -f 2- > /tmp/.repr
'test'=$(</tmp/.repr)
rm /tmp/.repr
}
And not as name:
repr() {
declare -p test | cut -d '=' -f 2- > /tmp/.repr
test=$(</tmp/.repr)
rm /tmp/.repr
}
How can I solve the problem?