Programming-Idioms

History of Idiom 205 > diff from v8 to v9

Edit summary for version 9 :
[C] Hmm, assigning "none" does not make much sense

Version 8

2019-09-29, 20:58:10

Version 9

2019-09-29, 20:59:52

Idiom #205 Get an environment variable

Read an environment variable with the name "FOO" and assign it to the string variable foo. If it does not exist or if the system does not support environment variables, assign a value of "none".

Idiom #205 Get an environment variable

Read an environment variable with the name "FOO" and assign it to the string variable foo. If it does not exist or if the system does not support environment variables, assign a value of "none".

Extra Keywords
envvar os system
Extra Keywords
envvar os system
Imports
#include <stdlib.h>
Imports
#include <stdlib.h>
Code
const char * foo = getenv("FOO");
Code
const char * foo = getenv("FOO");
if (foo == NULL) foo = "none";
Comments bubble
Returns a pointer to the value or NULL
Comments bubble
Returns a pointer to the value or NULL
Doc URL
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getenv.html
Doc URL
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getenv.html