Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

    $ stat "$(which stat)"

shellcheck or its online version http://www.shellcheck.net/ help a lot


sort by: page size:

Obligatory reference to shellcheck:

https://www.shellcheck.net/


Shellcheck helped me learn a lot about bash.

https://www.shellcheck.net/


Looks like that script could benefit from a couple of rounds of ShellCheck. http://www.shellcheck.net/

Nice script.

It's... uhhh... not shellcheck-clean.

https://shellcheck.net/


shellcheck, whilst not a script itself, I do find it useful when writing them.

- https://github.com/koalaman/shellcheck


If you are interested in this, you may find ShellCheck a useful tool.

It is a static analyzer for Shell, that looks for some of the problems cited in the post.

https://www.shellcheck.net


> linters for shell languages

Obligatory in case anyone hasn't seen it:

https://www.shellcheck.net/

Works as a web app or local tool.


I know enough bash to know a relevant shellcheck rule... Not sure that's enough to use it safely. :)

https://github.com/koalaman/shellcheck/wiki/SC2124


Following a style guideline is really important in scripts. But, having your scripts checked by ShellCheck [1] is really mandatory. Can’t imagine to write any script without it.

[1] https://www.shellcheck.net/


Everytime I see Shellcheck coming up, I have to mention shellharden[0] written by a colleague of mine. It is basically shellcheck but it applies the suggested changes automatically.

0: https://github.com/anordal/shellharden


Shellcheck helps a lot with this, I won't write shell without it anymore: https://www.shellcheck.net/

For those not familiar:

http://www.bash.org/?244321


Shellcheck [1] has a lot of issues with this script. You might consider refactoring it a little bit to pass without errors. Some of the warnings could probably be ignored.

[1] - https://www.shellcheck.net/


Shellcheck is amazingly impressive at catching issues with shell scripts. It makes it very hard to write a shell script that does the wrong thing.

Also, look at oilshell[1]; it is bash compatible out-of-the-box, but has several options to make it incompatible, but safer (e.g. no field splitting of parameter expansion by default, making quotes much less needed).

1: https://www.oilshell.org/


http://stackoverflow.com and http://serverfault.com/ have good shell scripting discussions

Try shellspec for tests. https://shellspec.info/

Don't forget to shellcheck¹ your script before checking it in. Also available in VSCode, IntelliJ, and others.

[1] https://www.shellcheck.net/


Best used in combination with shellcheck (https://www.shellcheck.net/), which checks your shell scripts for bugs.

I would also highly recommend shellcheck (https://www.shellcheck.net/) for useful error messages and warnings!
next

Legal | privacy