Skip to content
cstackpole edited this page Jul 23, 2014 · 7 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!

Contradictions

None I am aware of at the moment.

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally