| Some "small" useful scripts |
|---|
| for enhancing development or system-administrators tasks |
Currently, the biggest part of this repository is in a suite of shell scripts about build and checks that I use in some of my other repositories.
I tried to follow some conventions for my bash code:
- I tried to encapsulate most of the code in functions.
- Unless used as return values, variables in functions are defined
as local variables (
localkeyword ordeclare) with prefix "LFBFL_". - When used as return values, variables in functions are defined
as global variables (
declare -g) with prefix "@function_name@result". - Whenever a variable is no more modified after some point,
add the keyword
readonlyor usedeclare -r. - Whenever a variable will only contain integer values (or boolean
values as 0 or 1), use
declare -i. - I named bash files with suffixes ".exec.sh" when the script can be runned (executable, abbreviation stops before a vowel).
- I named bash files with suffixes ".libr.sh" when the script contains only functions definitions (library, abbreviation stops before a vowel).
- When some ".exec.sh" code is encapsulated into functions, either these functions can be reused and go in some ".libr.sh" file, either they are truly specific to this script and they are kept in ".exec.sh" file.
- When using
sourcebuiltin, although any path/filename with a slash will only be searched for from the current directory (tested), we add the prefix "./", to make it explicit. - We use mapfile instead of read -r most of the time, but with the following exceptions: real use of read -r to read the command line of the shell, comments (of course), and a file funny.sh where it is kind of required to use read -r.
- We replaced all echo calls by printf calls to follow "The Open Group Base Specifications" since at least 2 decades: "New applications are encouraged to use printf instead of echo.", https://pubs.opengroup.org/onlinepubs/000095399/.
But the files "pre-commit" and "post-commit" were not renamed,
since it is not possible to give them other names to use them as
pre-commit/post-commit hooks in git.