I've been having trouble with accessing environment variables from within a function. Basically, the script is like this:
function printusername(){
echo "You are logged in as " . $REMOTE_USER;
}
printusername();
but the function only prints "You are logged in as ". This is the same for any environment variables I try to access that aren't in the main script, if I make my script so it doesn't use functions at all, everything works fine, it's just inside functions that is has trouble.
How can I solve this problem? do I have to just pass environment variables as function parameters? are there any known issues with this?