POSIXLY:
$ : "${editor:=$(command -v emacs)}" "${editor:=/usr/bin/vi}"
$ printf '%s\n' "$editor"
emacs
Вы не можете выполнять расширение вложенных параметров в любых оболочках типа Bourne, кроме zsh
:
$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs
или:
editor=${commands[emacs]-$commands[vi]}