In this case, one reason to use printenv is that it is an external command, and so it is clearly and unambiguously seeing (and reporting) whatever the Bourne shell would export into the environment for a real command. In this specific case, it appears that set does not report such single-command variables (whether or not they have a value, eg 'FRED=barney set | grep FRED').(I am the author of the linked-to entry.)
1vuio0pswjnm7|2 years ago
_TwoFinger|2 years ago
It's not missing. PP is making a point about "single-command variables."
dcassett|2 years ago
If you add a semicolon then FRED is no longer a single command variable (it persists)
> on NetBSD, one can do this
Linux also does the expected thing:
$ FRED=barney printenv FRED
barney