I'm trying to write in bash what would look like this in PHP 7:
echo ${$branch . '_SSH'} ?? $default_SSH;
- Check for a variable which has a variable name.
- Fall back to another variable if it doesn't exist.
- echo the result.
Is there an equivalent one liner in bash?
this might be helping, although i'm not sure if it's the shortest/best solution::
however, always avoid to write "clever" code. be explizit and simple. Future-you will appreciate. ;-)