Crucible

I am currently working on and off on a side project and I named it crucible. It is to do with Shell scripts and I will explain briefly what it does and how.

Why crucible?

So the idea was to first name it anvil or ansible but those two names already exist in the DevOps world as other tools. So then I came up with the idea of a framework that can mould things and then you pour it like from a crucible into whatever shape you chose to make and replicate the scripts completely. In essence I wanted to make a virtualenv for shell scripts.

The obvious question is why do I wanted to make this. So the reason was mainly to have a nice framework for repeatable and quickly made shell scripts. All those manipulations that you might forget over time and only occasionally need. Like arrays in Bash, or date times, or navigation. There exist a collection of Bash functions but it was not nearly as nicely structured and you had to manually source them.

In addition to this all, I just wanted to see how far I can take one language that is designed to do a very limited set of things. See how far I can take this limited set and make it do things that are normal in other programming languages.

Structure

The structure of the side project is that for each of the shells I want to target:

I will have written functions that you can require. The entrypoint of the main shell script is a file called .mould . It contains the require function logic. Basically it will download the requirements and source them into your current script.

Then when you are done you call the pour command and it will produce a tarball that will hold the full script with dependencies so you can run it anywhere and everywhere.

Example functions

For example I made some functions pertaining to dealing with arrays in the shell. There even exists a map functionality that applies a function to every element of the array and thereby transforming the array in place. There exists some functions to deal with dates and logging.

Test harness

There is a test suite in place that just unit tests the functions to see if the input / output is what is expected. This was quite the thing to setup and maintain actually. Every script is checked with Shellcheck to see if it passes static code analysis.

Open Source

It is open source and the repository is located over here. There are some releases now there but they are haphazard at best.

Future

The future will contain that there will be modules for text, binary, files, network and processes and some more shells. Things like file navigation, file creation for example will all be there.

#code #bash