3 ms·
EADDRESS=$([[ "$1" == "" ]] && echo "noreply@example.com" || echo "$1") could be replaced with: EADDRESS={$1:-noreply@example.com} From the man page:
by alphapapa 10y ago
EADDRESS=$([[ "$1" == "" ]] && echo "noreply@example.com" || echo "$1")
could be replaced with:
EADDRESS={$1:-noreply@example.com}
From the man page:
${parameter:-word}
Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.
For:
EADDRESS=$(echo "$EADDRESS" | sed 's;@;%40;')
you could use:
EADDRESS=${EADDRESS/@/%40}
- xp84 10y agoCurious - exactly what man page do you find that in? I've always seen that construction but given that it just uses random punctuation it's impossible to Google it. I don't even know what those are called!!
- pstch 10y agoThe chapter on parameter subsitution in the LDP's Bash Scripting Guide is nice for this : http://tldp.org/LDP/abs/html/parameter-substitution.html http://tldp.org/LDP/abs/html/parameter-substitution.html
- alphapapa 10y agoThat's from the Bash man page. :) If you open it in less, you can do `/ :- RET` to search for `:-` and jump to it, which will take you to that part.