mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Adding page since it wasn't there when I first encountered it.
17
SC2116.md
Normal file
17
SC2116.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## SC2116 Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
a=$(echo $?)
|
||||
|
||||
### Correct code:
|
||||
|
||||
a="$?"
|
||||
|
||||
### Rationale:
|
||||
|
||||
Most of the time, this is an useless echo meaning it isn't doing anything that the Shell can't already do. Having the shell expand the contents for you is simpler and more reliable. Just remember to double quote the argument!
|
||||
|
||||
### Contraindications
|
||||
|
||||
None I am aware of at the moment.
|
Reference in New Issue
Block a user