I know that in Bash you can use the syntax
editor=${new_editor:-/usr/bin/vi}
which will set editor
to new_editor
if the variable new_editor
is not empty and to /usr/bin/vi
otherwise. Is it possible to produce similar one-liner, which will set editor
to output of some command and to some default value if the output is empty? Something like (only as example, this does not work)
editor=$( $(which emacs) :-/usr/bin/vi )
I know how to do it in several lines of code, but would like to know if an elegant solution exists.