bshchk.web/content/_index.md

825 B

+++ +++

why?

lets take this script:

rm -fr data.json
curl https://url.com/data.json -o data.json

the problem here is that curl might not be installed on second line, but the data is already deleted.

it will result in data.json being irreparably deleted and no way to reinstall it

solution

you could write up something like this and put it in the start:

if ! command -v curl; then
    echo no curl!
    exit 1
fi

but that's just not reliable and barely maintainable. so that's why i made this thing.

you can use it like this:

# program.sh
#!/usr/bin/env bash
curl https://url.com

then compile it like that: bshchk program.sh dist.sh.

also you can read the script from stdin: cat program.sh | bshchk - dist.sh, or get the output to stdout: bshchk program.sh > dist.sh