shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

Catch undefined commands / functions

Open functicons opened this issue 2 years ago • 1 comments

For new checks and feature suggestions

  • [x] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
  • [x] I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related

Is it possible to generate warning for undefined command / function? The use case is to catch typos. In practice, I'm okay to maintain a dictionary of command / function names.

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


#!/bin/bash

echa "hello world"

Here's what shellcheck currently says:

No issues detected!

Here's what I wanted or expected to see:

Unknown command "echa"

functicons avatar Sep 14 '22 18:09 functicons

maybe a sounds like match to catch common misspellings or such. it's hard to know what binaries are installed in the PATH of the system and so on.

brother avatar Sep 15 '22 08:09 brother

Shellcheck is extremly helpful. Thanks for this!

I would highly vote for - Indicating misspelled functions/shell commands.

However, searching executable paths may be time consuming. Furthermore, it will also yield false positives when the dev-environment is not the target machine.

Therefore I think that searching for misspelled commands/functions should not be the default. It should be activated by a command line option.

Many Thanks!

christophgil avatar Jan 22 '23 14:01 christophgil