You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
zsh: support omitted parameter name in ${:-word} expansions #1280
Zsh allows the parameter name to be omitted in expansions:
This is commonly combined with the (%) prompt expansion flag, which enables
prompt escape expansion, see man zshmisc for details.
./shfmt -ln zsh <<<'echo ${:-word}'# <standard input>:1:8: invalid parameter name# Get name of script, sourced file, or function currently being executed (%N)
./shfmt -ln zsh <<<'echo ${(%):-%N}'# <standard input>:1:11: invalid parameter name# Get absolute path of the file containing the source code currently being executed (%x)
./shfmt -ln zsh <<<'echo ${${(%):-%x}:a}'# <standard input>:1:13: invalid parameter name# Powerlevel10k instant prompt (very common in the wild)
./shfmt -ln zsh <<<'source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"'# <standard input>:1:66: invalid parameter name
zsh docs
${name-word}
${name:-word}
If name is set, or in the second form is non-null, then substitute its value; otherwise substitute word. In the second form name may be omitted, in which case word is always substituted.
Activity
syntax: support missing parameter expansion names in zsh
fix(deps): update module mvdan.cc/sh/v3 to v3.13.1 (#397)
chore(deps): update module mvdan.cc/sh/v3/cmd/shfmt to v3.13.1 (hetzn…