mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Created SC1077 (markdown)
29
SC1077.md
Normal file
29
SC1077.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# SC1077: For command expansion, the tick should slant left (` vs ´).
|
||||
|
||||
|
||||
### Problematic code:
|
||||
|
||||
echo "Your username is ´whoami´"
|
||||
|
||||
### Correct code:
|
||||
|
||||
echo "Your username is $(whoami)" # Preferred
|
||||
echo "Your username is `whoami`" # Deprecated, will give [SC2006]
|
||||
|
||||
### Rationale:
|
||||
|
||||
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. To help spot bugs, ShellCheck parses backticks and forward ticks interchangeably.
|
||||
|
||||
### Contraindications
|
||||
|
||||
If you want to write out literal forward ticks, such as fancyful ascii quotation marks:
|
||||
|
||||
echo "``Proprietary software is an injustice.´´ - Richard Stallman"
|
||||
|
||||
use single quotes instead:
|
||||
|
||||
echo '``Proprietary software is an injustice.´´ - Richard Stallman'
|
||||
|
||||
To nest forward ticks in command expansion, use `$(..)` instead of `` `..` ``.
|
Reference in New Issue
Block a user