Compare commits

...

3 Commits

Author SHA1 Message Date
b1ek 26236bf041
add repo link 2024-06-04 10:10:01 +10:00
b1ek da155aba57
minify html 2024-06-04 10:00:58 +10:00
b1ek c5d38c663f
add more info to index page 2024-06-04 10:00:50 +10:00
3 changed files with 46 additions and 3 deletions

View File

@ -7,12 +7,13 @@ compile_sass = true
# Whether to build a search index to be used later on by a JavaScript library # Whether to build a search index to be used later on by a JavaScript library
build_search_index = false build_search_index = false
minify_html = true
[markdown] [markdown]
# Whether to do syntax highlighting # Whether to do syntax highlighting
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola # Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
highlight_code = true highlight_code = true
minify_html = true
[extra] [extra]
# Put all your custom variables here # Put all your custom variables here

View File

@ -14,6 +14,8 @@ the problem here is that `curl` might not be installed on second line, but the d
it will result in `data.json` being irreparably deleted and no way to reinstall it it will result in `data.json` being irreparably deleted and no way to reinstall it
## solution ## solution
so generally, you would want to check if the dependencies of your bash script are installed, right?
you could write up something like this and put it in the start: you could write up something like this and put it in the start:
```sh ```sh
@ -23,12 +25,11 @@ if ! command -v curl; then
fi fi
``` ```
but that's just not reliable and barely maintainable. so that's why i made this thing. but that's just not reliable and barely maintainable. so that's why i made this thing. it parses your script, and then appends a small snippet at the earliest place in your program that would check if all deps are installed.
you can use it like this: you can use it like this:
```sh ```sh
# program.sh
#!/usr/bin/env bash #!/usr/bin/env bash
curl https://url.com curl https://url.com
``` ```
@ -36,3 +37,42 @@ curl https://url.com
then compile it like that: `bshchk program.sh dist.sh`. 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` 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`
it would output something like this:
```sh
#!/usr/bin/env bash
# This is the runtime dependency checker
# Please do not remove the following lines.
deps=('curl')
non_ok=()
for d in $deps
do
if ! command -v $d > /dev/null 2>&1; then
non_ok+=$d
fi
done
if (( ${#non_ok[@]} != 0 )); then
>&2 echo "RDC Failed!"
>&2 echo " This program requires these commands:"
>&2 echo " > $deps"
>&2 echo " --- "
>&2 echo " From which, these are missing:"
>&2 echo " > $non_ok"
>&2 echo "Make sure that those are installed and are present in \$PATH."
fi
unset non_ok
unset deps
# Dependencies are OK at this point
curl https://url.com
```
---
[website's source code available here](https://git.blek.codes/blek/bshchk.web)

View File

@ -12,6 +12,8 @@
<a href="/">home</a> <a href="/">home</a>
| |
<a href="/manual">manual</a> <a href="/manual">manual</a>
|
<a href="https://git.blek.codes/blek/bshchk">repo</a>
</p> </p>
<p style="margin-top:0;padding-top:0">bshchk - a dependency checker for bash scripts</p> <p style="margin-top:0;padding-top:0">bshchk - a dependency checker for bash scripts</p>
{% block content %}{% endblock %} {% block content %}{% endblock %}