Skip to main content
added 123 characters in body
Source Link
cuonglm
  • 158.2k
  • 41
  • 342
  • 420

POSIXLY:

$ : "${editor:=$(command -v emacs)}" "${editor:=/usr/bin/vi}"
$ printf '%s\n' "$editor"
emacs

You can't do nested parameter expansion in any Bourne-like shells but zsh:

$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs

or:

editor=${commands[emacs]-$commands[vi]}

You can't do nested parameter expansion in any Bourne-like shells but zsh:

$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs

POSIXLY:

$ : "${editor:=$(command -v emacs)}" "${editor:=/usr/bin/vi}"
$ printf '%s\n' "$editor"
emacs

You can't do nested parameter expansion in any Bourne-like shells but zsh:

$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs

or:

editor=${commands[emacs]-$commands[vi]}
deleted 135 characters in body
Source Link
cuonglm
  • 158.2k
  • 41
  • 342
  • 420

You can't do nested parameter expansion in any Bourne-like shells but zsh:

$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs

POSXILY:

$ editor=/usr/bin/vi
$ : "${editor:=$(command -v emacs)}"
$ printf '%s\n' "$editor"
/usr/bin/vi

You can't do nested parameter expansion in any Bourne-like shells but zsh:

$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs

POSXILY:

$ editor=/usr/bin/vi
$ : "${editor:=$(command -v emacs)}"
$ printf '%s\n' "$editor"
/usr/bin/vi

You can't do nested parameter expansion in any Bourne-like shells but zsh:

$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs
added 103 characters in body
Source Link
cuonglm
  • 158.2k
  • 41
  • 342
  • 420

You can't do nested parameter expansion in any Bourne-like shells but zsh:

$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs

POSXILY:

$ editor=/usr/bin/vi
$ : "${editor:=$(command -v emacs)}"
$ printf '%s\n' "$editor"
/usr/bin/vi

You can't do nested parameter expansion in any Bourne-like shells but zsh:

$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs

You can't do nested parameter expansion in any Bourne-like shells but zsh:

$ editor=${$(whence -p emacs):-/usr/bin/vi}
$ print -rl -- $editor
/usr/bin/emacs

POSXILY:

$ editor=/usr/bin/vi
$ : "${editor:=$(command -v emacs)}"
$ printf '%s\n' "$editor"
/usr/bin/vi
Source Link
cuonglm
  • 158.2k
  • 41
  • 342
  • 420
Loading