Skip to content
Vidar Holen edited this page Oct 4, 2015 · 5 revisions

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!

Exceptions

None I am aware of at the moment.

Clone this wiki locally