APP_MODE=staging is already a shell variable.
Pass the value to subsequently started child processes.
Which command should be added?
export NAME marks an existing shell variable for inheritance by child processes.
Detailed explanation
set APP_MODEIncorrect. set does not mark APP_MODE for export.
Incorrect. set does not mark APP_MODE for export.
export APP_MODECorrect. export APP_MODE adds the export attribute so child processes receive the value.
Correct. export APP_MODE adds the export attribute so child processes receive the value.
unset APP_MODEIncorrect. unset deletes the variable.
Incorrect. unset deletes the variable.
alias APP_MODEIncorrect. alias defines command substitution, not an environment variable.
Incorrect. alias defines command substitution, not an environment variable.
Try it yourself
An example you can run in a temporary verification environment.
bash --noprofile --norc -c 'APP_MODE=staging; export APP_MODE; bash -c '\''printf "%s\n" "$APP_MODE"'\'''Expected result
stagingKey points
- Shell versus environment variable
- Export attribute
- Inheritance
Notes
- Environment: GNU Bash 5.2 / 一時子シェル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.