-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.md.tpl
More file actions
110 lines (87 loc) · 4.3 KB
/
README.md.tpl
File metadata and controls
110 lines (87 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# DevOrSysAdminScripts
[![CodeFactor-badge]][CodeFactor-package-page]
[![Codacy-badge]][Codacy-package-page]
![GitHub-top-language-badge]
![GitHub-code-size-in-bytes-badge]
[![Security:bandit:badge]][Bandit-GitHub.com]
[![Code-style:black:badge]][Black-GitHub.com]
[![Imports:isort:badge]][Isort-GitHub.io]
[![Typecheck:mypy:badge]][Typecheck-mypy-lang.org]
[![Linting:pylint:badge]][Pylint-GitHub.com]
[![Linting:ruff:badge]][Ruff-GitHub.com]
| **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).
- 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`.
- 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/>.
- We used `_?i_` or `_?j_`, etc. in integer variables names in Bash
scripts.
[CodeFactor-badge]: https://www.codefactor.io/repository/github/\
llyaudet/DevOrSysAdminScripts/badge
[CodeFactor-package-page]: https://www.codefactor.io/repository/\
github/llyaudet/DevOrSysAdminScripts
[Codacy-badge]: https://app.codacy.com/project/badge/Grade/\
3dd6ef85e8db4460991d1ebc404b68dd
[Codacy-package-page]: https://app.codacy.com/gh/LLyaudet/\
DevOrSysAdminScripts/dashboard?utm_source=gh&utm_medium=referral\
&utm_content=&utm_campaign=Badge_grade
[GitHub-top-language-badge]: https://img.shields.io/github/\
languages/top/llyaudet/DevOrSysAdminScripts
[GitHub-code-size-in-bytes-badge]: https://img.shields.io/github/\
languages/code-size/llyaudet/DevOrSysAdminScripts
[Security:bandit:badge]: https://img.shields.io/badge/\
security-bandit-yellow.svg
[Bandit-GitHub.com]: https://github.com/PyCQA/bandit
[Code-style:black:badge]: https://img.shields.io/badge/\
code%20style-black-000000.svg
[Black-GitHub.com]: https://github.com/psf/black
[Imports:isort:badge]: https://img.shields.io/badge/\
%20imports-isort-%231674b1?style=flat&labelColor=ef8336
[Isort-GitHub.io]: https://pycqa.github.io/isort/
[Typecheck:mypy:badge]: https://www.mypy-lang.org/static/\
mypy_badge.svg
[Typecheck-mypy-lang.org]: https://mypy-lang.org/
[Linting:pylint:badge]: https://img.shields.io/badge/\
linting-pylint-yellowgreen
[Pylint-GitHub.com]: https://github.com/pylint-dev/pylint
[Linting:ruff:badge]: https://img.shields.io/endpoint?url=\
https://raw.githubusercontent.com/astral-sh/ruff/main/assets/\
badge/v2.json
[Ruff-GitHub.com]: https://github.com/astral-sh/ruff