4 ms·
shellcheck /scriptsdir/script I noticed this in the output. ^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang. Being new to sh
by 3xblah 7y ago
shellcheck /scriptsdir/script
I noticed this in the output.
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang.
Being new to shellcheck, not familar with options or what it does, so I hastily and erroneously typed:
shellcheck -shell=bash script
Note I learned UNIX via NetBSD. I prefer and use their version of ash for both interactive and scripting use.1 I never got used to "--" GNU-style long options. I sometimes type a single "-" out of habit. Anyway, here is the output I got from shellcheck:
Unknown shell: hell=bash
I agree with shellcheck.
Although there may be some irony in the fact it cannot sort out it own argument parsing.
1. I do not use other scripting languages such as Python, Perl, Ruby, etc. That means, e.g., for quick and dirty one-offs and prototyping, I can omit the shebang. Debian's "dash" scripting shell is derived from NetBSD's ash, the one I choose for interactive use.
- inetknght 7y agoThe 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) https://en.wikipedia.org/wiki/Shebang_(Unix)
- deleted 7y ago[deleted]
- deleted 7y ago[deleted]
- therein 7y agoSounds like it would be content with `-sbash`.