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 new plain assignment is not inherited unless the variable was already exported.
export EDITOR=nanoCorrect. export EDITOR=nano sets and exports the variable.
Correct. export assigns nano and exposes EDITOR to future child processes.
set EDITOR nanoIncorrect. set does not use this form to create an exported environment variable.
Incorrect. set does not create this exported variable in the shown form.
echo nano > EDITORIncorrect. This writes to a file named EDITOR rather than setting a variable.
Incorrect. Redirection writes a file and does not change the process environment.
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子プロセス
- Use a temporary file and harmless edits when testing vi commands.
- Confirm the behavior on the target vi/Vim implementation.
Foundation review
Place the operation
A child program can read an exported value; a plain shell variable remains private to the current shell unless already exported.
Check the side effect
Set EDITOR, start a child shell, and print its value.