Skip to content

LLyaudet/DevOrSysAdminScripts

Repository files navigation

DevOrSysAdminScripts

CodeFactor-badge Codacy-badge GitHub-top-language-badge GitHub-code-size-in-bytes-badge Security:bandit:badge Code-style:black:badge Imports:isort:badge Typecheck:mypy:badge Linting:pylint:badge Linting:ruff:badge

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 (local keyword or declare) 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 readonly or use declare -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 source builtin, 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.

About

Some small useful scripts

Resources

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors