010-100 · Question #17
Which command is used to make a shell variable known to subsequently executed programs?
The correct answer is A. export. The export builtin makes a shell variable part of the environment so child processes can access it.
Question
Which command is used to make a shell variable known to subsequently executed programs?
Options
- Aexport
- Bannounce
- Cenv
- Dtransfer
- Emv
How the community answered
(40 responses)- A73% (29)
- B3% (1)
- C8% (3)
- D15% (6)
- E3% (1)
Why each option
The export builtin makes a shell variable part of the environment so child processes can access it.
The export command in POSIX-compliant shells adds a variable to the shell's export list, causing it to be inherited by all subsequently executed child processes as an environment variable. Without export, a variable exists only in the current shell's local scope and is invisible to any subprocess or program launched from that shell. This is the standard mechanism for passing configuration values such as PATH or custom settings to programs invoked from a shell session.
announce is not a valid shell command or Unix utility and does not exist in standard shell environments.
env can display the current environment or run a program with a modified environment, but it does not mark a shell variable for automatic inheritance by future child processes.
transfer is not a valid shell command or Unix utility.
mv is a filesystem utility that moves or renames files and directories and has no relationship to variable scope or environment inheritance.
Concept tested: Exporting shell variables to child processes
Source: https://www.gnu.org/software/bash/manual/bash.html#index-export
Topics
Community Discussion
No community discussion yet for this question.