Pattern: Use of ´
for command expansion
Issue: -
In some fonts it's hard to tell ticks apart, but Bash strongly distinguishes between backticks (grave accent `
), forward ticks (acute accent ´
) and regular ticks (apostrophe '
).
Backticks start command expansions, while forward ticks are literal.
Example of incorrect code:
echo "Your username is ´whoami´"
Example of correct code:
echo "Your username is $(whoami)" # Preferred
echo "Your username is `whoami`" # Deprecated, will give [SC2006]
If you want to write out literal forward ticks, such as fancy ASCII quotation marks:
echo "``The Internet is becoming the town square for the global village of tomorrow.´´ - Bill Gates"
use single quotes instead:
echo '``The Internet is becoming the town square for the global village of tomorrow.´´ - Bill Gates'
To nest forward ticks in command expansion, use $(..)
instead of `..`
.