I'm scripting out a set of commands for git, and in typical git fashion, I'd like to launch the editor for the user to review and edit a file as input. (This is the style used for commit messages and for interactive rebase.) I can invoke the editor explicitly:
vim /tmp/myfile
But this ignores the user's settings. I could attempt to read the configuration from git config:
editor=$(git config core.editor)
$editor /tmp/myfile
But this won't work if there isn't an explicit setting for core.editor anywhere. $editor would just be the empty string in that case.
How can I invoke the user's editor?
Note: I am not looking to edit the configuration file.