this post was submitted on 04 Jun 2024
32 points (97.1% liked)

Linux

5230 readers
135 users here now

A community for everything relating to the linux operating system

Also check out [email protected]

Original icon base courtesy of [email protected] and The GIMP

founded 1 year ago
MODERATORS
32
submitted 5 months ago* (last edited 5 months ago) by [email protected] to c/[email protected]
 

https://bshchk.blek.codes/

this is a program that parses a bash file, collects all dependencies and then adds a snippet at the start of the file that would check if they are installed at the earliest point possible, to prevent situations where a program just fails in the middle of execution because some random dependency is not installed

i've originally made this to use it in another project, but might just as well share with y'all

top 4 comments
sorted by: hot top controversial new old
[–] [email protected] 10 points 5 months ago* (last edited 5 months ago) (1 children)

Wanted to perhaps introduce you to using nix along with direnv and flakes to make your dependencies declarative rather than determined by factors beyond your control.

In my bash scripts, I often create a .envrc file that points to my flake and sits alongside the bash file. Then, when I navigate into the directory of the script/project, I can make direnv and nix automatically load all dependencies (which virtually guarantees them eliminating the need to check for them).

[–] [email protected] 3 points 5 months ago

thats not exactly the point of bshchk. the idea is to have it run on any platform, in a single bash script, just as amber does (the another project mentioned earlier)

[–] [email protected] 3 points 5 months ago (1 children)

This is great. Good complimentary functionality to ShellCheck (linter).

[–] [email protected] 2 points 5 months ago

its not exactly a complimentary functionality to shellcheck, it just uses it as a dependency