C Learner
C Learner

Reputation: 11

Environment Variables in my own C Linux Shell?

I'm writing my own C Linux shell.

But I have to get and set environment variables.

I've had a little success using getenv("HOME") in my change directory part.

How do you get and set environment variables in my own shell though?

Upvotes: 1

Views: 400

Answers (1)

tgfuellner
tgfuellner

Reputation: 204

You can use:

int setenv(const char *name, const char *value, int overwrite);

to change the environment belonging to Your current process. All child processes You create will inherit the changed environment.

Upvotes: 1

Related Questions