I would like to use parameter substitution to compute a path based on
- a variable being defined
- a first default directory to be used if it exists
- a file inside the $HOME directory to be used if neither of 1 or 2 are available.
The variable (#1) and the file in $HOME (#3) are easy:
${KEEPER_HOME:-$HOME/.keeper}
But is there a parameter/variable substitution syntax in Zsh for #2? If we imagined that ||
did this, I would be looking for something like this:
${KEEPER_HOME:-$HOME/.config/keeper||$HOME/.keeper}
Of course I can do it with test
inside $(
...)
but I am hoping that something more concise and readable exists.