A programming environment for shell scripts
- Header files with bash_preproc
- Documentation generation with shdoc
- Enforced, objective formatting with
shfmt
- Shellcheck to prevent potentially broken code from running
- Creates binaries from your code with
shc
First, download bash_preproc and shdoc. Then download Clam with sudo make install
. To create a project, run clam new {name}
. You can edit src/main.sh
as you want, and when you want to compile your project, run clam compile
in the root of your project. You can also use clam run
to run your project after compiling.
If your code ever gets too messy, and you want to format it, run clam fmt
.
If you want to separate your code into libraries, you can use Clam's header capabilities (provided by bash_preproc). Standard headers are located in /usr/include/bash/
, but you can use local headers.
Headers take two forms:
#include <global.sh>
#include "local.sh"
The <>
and ""
denote whether you want to use global headers or local headers, respectively. Local headers should be added to the src/
directory.
File tree:
.
└── src
├── main.sh
└── msg.sh
Contents of main.sh
:
#!/bin/bash
#include "msg.sh"
msg 'Hello world!'
Contents of msg.sh
:
#!/bin/bash
function msg() {
echo -e "> $*"
}
When compiled, the final file before being turned into a binary will look like this:
#!/bin/bash
function msg() {
echo -e "> $*"
}
msg 'Hello world!'
Familiarize yourself with how to use shdoc first. When you are done creating your definitions, run clam docs
to create markdown files with all your definitions in docs/${file}.md
.