koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
35.53k stars 1.74k forks source link

SC2039 "In POSIX sh, echo flags are undefined." triggered for /bin/echo #1593

Open ribx opened 5 years ago

ribx commented 5 years ago

For bugs

Here's a snippet or screenshot that shows the problem:

#!/bin/sh
/bin/echo -e "test\ntest"

Here's what shellcheck currently says:

Line 2:
/bin/echo -e "test\ntest"
          ^-- SC2039: In POSIX sh, echo flags are undefined.

Here's what I wanted or expected to see:

When I use /bin/echo it should not complain about "echo in POSIX sh", as I am using the binary and not the shell internal function.

abitrolly commented 1 week ago

@ribx maybe it is better to switch to printf for good? /bin/echo own help recommends it.

$ /bin/echo --help
...
NOTE: printf(1) is a preferred alternative,
which does not have issues outputting option-like strings.