I have a ridiculous question due to a ridiculous problem.
Normally if I want to get the contents of an environment variable in UNIX shell, I can do
( set -o posix ; set ) | grep $var
search for all unix-compatible format variables been used
Do you mean something like this:
ENV() {
printf 'echo $%s\n' $1 | sh
}
This works in plain old Bourne shell.
You can do:
printenv VARIABLE_NAME
type the following command in terminal, it will display all the list of environment variables
printenv
now print the wanted variable like this:
echo $VARIABLENAME
How about this:
myVariable=$(env | grep VARIABLE_NAME | grep -oe '[^=]*$');
The solution really depends on what the restrictions are why you can't use a simple $VAR
. Maybe you could call a shell that doesn't have the restrictions and let this sub-shell evaluate the variable:
bash -c 'echo $VAR'