Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The error message is quite clear:

    SC2148: Tips depend on target shell and yours is unknown. Add a shebang.
If you google what a shebang is, the top link for me is a Wikipedia article on the subject [0]. A shebang is basically just a line (always the first line) in a file which tells the operating system what program to invoke to execute the script. There are different shells beyond just bash, so shellcheck wants to know which flavor the shell is written for and uses the shebang to figure it out.

I always have the top of my shell scripts with a shebang, even if the script isn't intended to be directly executed.

Pick the user's bash from PATH environment:

    #!/usr/bin/env bash
Or specify a specific bash:

    #!/bin/bash
Or use whatever plain-shell is installed:

    #!/bin/sh
Or maybe it's a Python script:

    #!/usr/bin/env python3
Or it's a text file:

    #!/usr/bin/env vi
If you're not using shebangs then you're probably writing your scripts wrongly.

[0] https://en.wikipedia.org/wiki/Shebang_(Unix)





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: