-
Notifications
You must be signed in to change notification settings - Fork 0
Environment
sarahmss edited this page Dec 11, 2021
·
3 revisions
To understand Unix behavior we can look at the syscalls (the basic API dor interacting with the kernel and OS) such as the exec family of calls.
The initial argument for these functions is the name of a file that is to be executed.
-
execle() and execvpe()functions allow the caller to specify the environment of the executed program via the argumentenvp(an array of pointers to null-terminated strings terminated by a NULL pointer). - Other functions take the environment for the new process image from the external variable which works such as a global dictionary
extern char **environ
- A variable is a container that has a defined value that can change.
- They allow changing a part of the command that is to be executed.
- Every shell has a set of attached variables
- the Variable SHELL contains the path to the current shell. While Environment variables are 'global' and shared by all shells started AFTER variable is defined, Shell's variables are ONLY present in the shell in which they were defined. Since that, environment variables are inherited by child shells but shell variables are not.
The '$' character introduces parameter expansion, command substitution, or arithmetic expansion.
- env: Exhibits all the environment variables.
- export: This allows you to configure and share environment variables between different programs and libraries accessed from the same terminal.
- unset: Delete values of environment variables.