Tell child processes started from the current shell to use nano as the default editor.
Use the EDITOR environment variable.
Which command is appropriate?
export EDITOR=nano assigns the value and marks it for inheritance by child processes that consult EDITOR.
Detailed explanation
EDITOR=nanoIncorrect. A non-exported shell variable is not inherited by child processes.
Incorrect. A non-exported shell variable is not inherited by child processes.
export EDITOR=nanoCorrect. export EDITOR=nano sets and exports the variable.
Correct. export EDITOR=nano sets and exports the variable.
set EDITOR nanoIncorrect. set does not use this form to create an exported environment variable.
Incorrect. set does not use this form to create an exported environment variable.
echo nano > EDITORIncorrect. This writes to a file named EDITOR rather than setting a variable.
Incorrect. This writes to a file named EDITOR rather than setting a variable.
Try it yourself
An example you can run in a temporary verification environment.
export EDITOR=nano; sh -c 'printf "%s\n" "$EDITOR"'Expected result
nanoKey points
- EDITOR is an environment variable
- export passes it to children
- nano and emacs are possible values
Notes
- Environment: Bash 5.x / POSIX sh子プロセス
- 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.