Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shellcheck gave me no error #1358

Closed
YvesZHI opened this issue Oct 9, 2018 · 2 comments
Closed

shellcheck gave me no error #1358

YvesZHI opened this issue Oct 9, 2018 · 2 comments
Labels
would have been awesome Features that would have been awesome, but which are currently too impractical

Comments

@YvesZHI
Copy link

YvesZHI commented Oct 9, 2018

I'm working on Ubuntu 16.04.3 and I've installed the shellcheck with the command apt install shellcheck.

Now I have such a bash script named test.sh:

#!/bin/bash

ssssss
aaaaaa

Obviously there are two errors as ssssss and aaaaaaa are illegal commands. However, when I execute shellcheck test.sh, I get nothing as output. It doesn't seem that the command shellcheck work as expected on my system.

@orbea
Copy link

orbea commented Oct 15, 2018

They may not be illegal commands, the user could have a ssssss and / or aaaaaa executable on their system. Shellcheck should not assume what users do or do not call their commands and I do not think this is a bug.

@koalaman koalaman added the would have been awesome Features that would have been awesome, but which are currently too impractical label Oct 16, 2018
@koalaman
Copy link
Owner

I would love if ShellCheck was able to correctly determine which commands will not be found when the script runs, but unfortunately this can't be done. It's equivalent to trying to predict which filenames will or won't exist on the system at the time when you run the script. Whitelisting and searching PATH would be possible options, but they're fragile and problematic in their own ways.

If you just want to test your script on something that will produce useful warnings to try it out, you can e.g. use shellcheck.net's example:

#!/bin/sh
## Example of a broken script.
for f in $(ls *.m3u)
do
  grep -qi hq.*mp3 $f \
    && echo -e 'Playlist $f contains a HQ file in mp3 format' 
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
would have been awesome Features that would have been awesome, but which are currently too impractical
Projects
None yet
Development

No branches or pull requests

3 participants