So there's $PWD, $PATH, $USERNAME and all that. I've been working on my own shell and I've just today introduced environment variables. The way I'm doing it is by creating strings called pwd, path and all so when there's a command to echo, say, $PWD I tell it to print pwd. Is this the same thing bash does? I don't yet have the provision to set environment variables but I'll work on that, I guess. My main question would be where and how actual shells do it.
Another somewhat related question, how is printenv related to all this? Because printenv is a binary and it always prints the bash environment variables, not of the shell I'm currently using to run it in the first place (obviously, how would it detect the strings in my program I've set to be my path and pwd) so where does it get these from?