Is setting the EDITOR
environment variable to :
to mean no-op supported behavior in Unix? Or is it special to Git?
I stumbled across this example of passing EDITOR=:
to Git to short-circuit any attempt to launch an editor:
# Amend the commit, reusing the commit message
EDITOR=: git commit --amend
But hang on a sec. Why does that work? The EDITOR
environment variable should be set to point to an editor executable in your PATH
, like EDITOR=vim
and such. After doing some digging, I've found that Git explicitly checks the editor value against :
and does not launch an editor in that case. (See commit.c for the gory details.)
So to get back to the question, it seems Git supports :
as a no-op editor, and it does this by special-casing. Is :
even a legal value for EDITOR
, or something of a convention supported by some programs? (An alternative would be to set EDITOR=echo
or EDITOR=touch
so that the editor is invoked as touch FILE
, leaving FILE
unmodified.)
Bonus
Using :
to mean no-op for EDITOR
seems oddly similar to how the :
Bash builtin is the no-op command equivalent to true
. Coincidence?