@renault-digital/bash-base 2.4.1 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +83 -10
- package/README.md +87 -6
- package/bin/bash-base +596 -312
- package/docs/bash-zsh-compatibility.md +202 -0
- package/docs/coverage.md +289 -0
- package/docs/design-principles.md +176 -0
- package/docs/references.md +122 -68
- package/docs/roadmap.md +289 -0
- package/man/bash-base.1 +71 -4
- package/package.json +4 -3
- package/scripts/test-shell-compat.sh +391 -0
- package/scripts/test.sh +82 -14
- package/spec/array.spec.sh +8 -2
- package/spec/coverage_edges.spec.sh +88 -0
- package/spec/coverage_zsh_array_map.spec.sh +24 -0
- package/spec/process.spec.sh +109 -15
- package/spec/reflection.spec.sh +1 -1
- package/spec/spec_helper.sh +17 -0
- package/spec/string.spec.sh +14 -17
- package/src/alias.sh +35 -4
- package/src/argument.sh +222 -124
- package/src/array.sh +96 -98
- package/src/constant.sh +1 -1
- package/src/document.sh +17 -11
- package/src/out.sh +26 -15
- package/src/process.sh +4 -4
- package/src/reflection.sh +76 -17
- package/src/string.sh +92 -27
- package/src/tool.sh +28 -12
package/CONTRIBUTING.md
CHANGED
|
@@ -7,21 +7,93 @@
|
|
|
7
7
|
|
|
8
8
|
This project and everyone participating in it is governed by the [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
|
|
9
9
|
|
|
10
|
+
## CI test matrix
|
|
11
|
+
|
|
12
|
+
Use the [CI test matrix](docs/coverage.md#ci-test-matrix) to distinguish runner
|
|
13
|
+
operating systems, tested interpreters, full-suite and selected test runs, and
|
|
14
|
+
coverage report destinations. Keep it aligned with changes to the workflow and
|
|
15
|
+
test entry points. A 100% line union is not a per-environment test guarantee.
|
|
16
|
+
|
|
10
17
|
## Submit an issue
|
|
11
18
|
|
|
12
|
-
|
|
19
|
+
Search the existing issues before opening a report or suggestion on the
|
|
20
|
+
[issues page](https://github.com/renault-digital/bash-base/issues/new/choose).
|
|
21
|
+
|
|
22
|
+
For a bug report, include a minimal reproduction, expected and actual behavior,
|
|
23
|
+
the Bash-base version or commit, the actual Shell and its version, the operating
|
|
24
|
+
system, and the installation/loading method. Include stdout, stderr and exit
|
|
25
|
+
status when relevant. Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md)
|
|
26
|
+
and remove credentials and other sensitive information from examples and logs.
|
|
27
|
+
|
|
28
|
+
For a feature request, describe the task and the difficulty first. Unknown
|
|
29
|
+
implementation details are not a reason to withhold a useful use case.
|
|
30
|
+
|
|
31
|
+
## Proposing a feature
|
|
32
|
+
|
|
33
|
+
Consult the [roadmap](docs/roadmap.md) for current priorities, dependencies and
|
|
34
|
+
acceptance criteria. A roadmap entry is an investigation direction, not an
|
|
35
|
+
approved API or a guaranteed release. Record actionable tasks and results in
|
|
36
|
+
issues and pull requests.
|
|
37
|
+
|
|
38
|
+
Start with the [design principles](docs/design-principles.md). Bash-base accepts
|
|
39
|
+
features to reduce recurring command-composition and scripting costs, not to
|
|
40
|
+
maximize the number of helpers or reproduce another language's standard library.
|
|
41
|
+
|
|
42
|
+
Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and
|
|
43
|
+
describe a concrete task, the difficulty it creates, and the approaches already
|
|
44
|
+
considered. A request does not need a finished API design or implementation;
|
|
45
|
+
identify unknowns explicitly so they can be discussed.
|
|
13
46
|
|
|
14
|
-
Before
|
|
47
|
+
Before merging an implementation, the contributor and maintainer should resolve:
|
|
15
48
|
|
|
16
|
-
|
|
49
|
+
| Question | Evidence expected for implementation review |
|
|
50
|
+
| --- | --- |
|
|
51
|
+
| What recurring problem does this solve? | A representative use case and the research, implementation, verification or maintenance work it avoids. |
|
|
52
|
+
| Why does this belong in Bash-base? | A clear connection to command arguments, outputs, execution or automation logic; comparison with built-ins, existing helpers and external tools. |
|
|
53
|
+
| What is the public contract? | Inputs, outputs, exit statuses, side effects, input boundaries and a realistic composition example. |
|
|
54
|
+
| What supports its reliability? | Relevant regression, boundary-input and supported-environment tests, including error paths. |
|
|
55
|
+
| What changes for existing users? | A compatibility assessment, any migration requirements, dependencies and maintenance costs. |
|
|
56
|
+
|
|
57
|
+
Preserve the existing regression and mandatory coverage gates. Coverage is
|
|
58
|
+
necessary evidence, not proof of all branches, inputs or security properties.
|
|
59
|
+
Do not relax a gate or silently change an existing API to make a new feature fit.
|
|
60
|
+
|
|
61
|
+
Document public helper behavior in its source comments as required by the
|
|
62
|
+
existing LiveDoc workflow. Keep shared design principles in the design-principles
|
|
63
|
+
reference and feature-specific rationale in the issue or pull request; neither
|
|
64
|
+
replaces generated API documentation.
|
|
17
65
|
|
|
18
66
|
## Code Contribution
|
|
19
67
|
|
|
20
|
-
|
|
68
|
+
Code, tests, documentation and CI improvements can be submitted through pull requests.
|
|
21
69
|
|
|
22
70
|
A pull request should remain focused in scope and avoid containing unrelated commits.
|
|
23
71
|
|
|
24
|
-
|
|
72
|
+
### Validation and compatibility
|
|
73
|
+
|
|
74
|
+
Behavior changes must include appropriate regression and boundary tests for the
|
|
75
|
+
supported environments. Preserve existing Bash behavior and the documented
|
|
76
|
+
Bash/zsh compatibility boundary; proposed design principles do not silently
|
|
77
|
+
change a current helper's contract.
|
|
78
|
+
|
|
79
|
+
Keep the existing regression, compatibility and mandatory 100% measurable-line
|
|
80
|
+
coverage gates. Do not weaken a gate, hide uncovered code or add meaningless
|
|
81
|
+
tests merely to obtain a passing result. Coverage does not establish complete
|
|
82
|
+
branch coverage, arbitrary-input safety or the absence of security defects.
|
|
83
|
+
|
|
84
|
+
Documentation-only changes do not require artificial test-suite changes when
|
|
85
|
+
executable behavior is unchanged. Explain that scope in the pull request and
|
|
86
|
+
validate the changed text, examples, links or metadata as appropriate. This is
|
|
87
|
+
not an exemption from the required CI status checks or coverage gate.
|
|
88
|
+
|
|
89
|
+
Record the commands actually run, their results, and relevant Shell/OS versions.
|
|
90
|
+
Distinguish completed checks from pending CI and checks that were not run. Do
|
|
91
|
+
not equate a local check or a release preview with a successful real publish.
|
|
92
|
+
|
|
93
|
+
Review the current release configuration before merging, including documentation
|
|
94
|
+
changes. Do not assume a `docs:` commit is excluded from release automation.
|
|
95
|
+
|
|
96
|
+
### Understand the technology stack
|
|
25
97
|
|
|
26
98
|
- Works with git, npm and docker
|
|
27
99
|
|
|
@@ -32,7 +104,7 @@ A pull request should remain focused in scope and avoid containing unrelated com
|
|
|
32
104
|
- BDD
|
|
33
105
|
- BDD test with [ShellSpec](https://shellspec.info)
|
|
34
106
|
- Code coverage with [Kcov](http://simonkagstrom.github.io/kcov/index.html) and [codecov](https://codecov.io)
|
|
35
|
-
- 100% coverage
|
|
107
|
+
- 100% measurable-source-line coverage under the required coverage gate
|
|
36
108
|
|
|
37
109
|
- Respect [Semantic Versioning 2.0.0](https://semver.org/) and [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/)
|
|
38
110
|
- Help input commit message
|
|
@@ -61,7 +133,7 @@ A pull request should remain focused in scope and avoid containing unrelated com
|
|
|
61
133
|
- CICD Workflow config with [NPM](https://docs.npmjs.com/about-npm/) and [Github actions](https://docs.github.com/en/actions)
|
|
62
134
|
|
|
63
135
|
|
|
64
|
-
|
|
136
|
+
### Notes
|
|
65
137
|
|
|
66
138
|
- in commit message template, the default issuePrefixes: `['#']`
|
|
67
139
|
|
|
@@ -70,7 +142,7 @@ A pull request should remain focused in scope and avoid containing unrelated com
|
|
|
70
142
|
- Don't modify the files `bin/`, `man/` and `docs/references.md`, they will generated automatically by semantic-release.
|
|
71
143
|
|
|
72
144
|
|
|
73
|
-
|
|
145
|
+
### How to do it?
|
|
74
146
|
|
|
75
147
|
1. Submit an issue, get the issue number, and assign it to you.
|
|
76
148
|
|
|
@@ -88,7 +160,7 @@ A pull request should remain focused in scope and avoid containing unrelated com
|
|
|
88
160
|
npm ci
|
|
89
161
|
```
|
|
90
162
|
|
|
91
|
-
1.
|
|
163
|
+
1. Make the focused change. Add or update tests for behavior changes and preserve the mandatory coverage gate. For documentation-only changes, follow the validation requirements above instead of adding unrelated tests.
|
|
92
164
|
|
|
93
165
|
1. Commit your changes in logical chunks. Please see the [commit message guidelines](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines).
|
|
94
166
|
|
|
@@ -109,7 +181,8 @@ A pull request should remain focused in scope and avoid containing unrelated com
|
|
|
109
181
|
npm test
|
|
110
182
|
npm run lint
|
|
111
183
|
# npm run lint:commit
|
|
112
|
-
#
|
|
184
|
+
# Optional local coverage diagnostic; not a replacement for the required gate:
|
|
185
|
+
# npm run test:coverage
|
|
113
186
|
```
|
|
114
187
|
|
|
115
188
|
1. Open a pull request with a clear title and description in template
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://github.com/renault-digital/bash-base/blob/master/LICENSE)
|
|
4
4
|
[](https://github.com/renault-digital/bash-base/search?l=Shell)
|
|
5
5
|
[](https://codecov.io/gh/renault-digital/bash-base)
|
|
6
|
-
[](https://github.com/renault-digital/bash-base/actions/workflows/cicd.yml)
|
|
7
7
|
[](https://conventionalcommits.org)
|
|
8
8
|
[](https://github.com/semantic-release/semantic-release)
|
|
9
9
|
[](https://github.com/renault-digital/bash-base/releases/latest)
|
|
@@ -14,15 +14,83 @@
|
|
|
14
14
|
|
|
15
15
|
## Goal
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**Reusable Bash/zsh utilities for reliable command composition and automation.**
|
|
18
18
|
|
|
19
|
-
Bash-base
|
|
19
|
+
Bash-base helps developers focus on what their shell scripts do, rather than
|
|
20
|
+
repeatedly researching how every low-level operation should work.
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
Its starting point is a recurring cost: searching for a Shell implementation,
|
|
23
|
+
comparing alternatives, experimenting with edge cases, and testing the result
|
|
24
|
+
across supported environments. Saving a few lines is useful; avoiding that
|
|
25
|
+
repeated implementation and verification work is the more important goal.
|
|
26
|
+
|
|
27
|
+
Bash-base provides reusable, tested functions for expressing command-oriented
|
|
28
|
+
logic through higher-level APIs. String and array operations support this goal:
|
|
29
|
+
organizing command arguments, transforming outputs, and expressing automation
|
|
30
|
+
logic. They are means to compose commands, not an attempt to build a complete
|
|
31
|
+
general-purpose application framework in Shell.
|
|
32
|
+
|
|
33
|
+
### Design priorities
|
|
34
|
+
|
|
35
|
+
- **Pain-driven:** address recurring scripting problems, not a target number of
|
|
36
|
+
functions.
|
|
37
|
+
- **Contract-driven:** make inputs, outputs, exit statuses and side effects
|
|
38
|
+
explicit, with interfaces that are understandable and work well together.
|
|
39
|
+
- **Evidence-driven:** use regression and cross-shell tests to support
|
|
40
|
+
reliability claims within the documented compatibility boundary.
|
|
41
|
+
- **Predictable reuse:** preserve existing behavior and favor fixed-version,
|
|
42
|
+
local loading where reproducible or offline execution matters.
|
|
43
|
+
|
|
44
|
+
These priorities guide maintenance and new API design; they do not assert that
|
|
45
|
+
every existing helper is side-effect-free or safe for arbitrary input. Read the
|
|
46
|
+
[design principles](docs/design-principles.md),
|
|
47
|
+
[API reference](docs/references.md), and
|
|
48
|
+
[Bash/zsh compatibility contract](docs/bash-zsh-compatibility.md) for scope and
|
|
49
|
+
boundaries. Proposed data types or helpers are not available APIs until they
|
|
50
|
+
have been implemented, tested and documented.
|
|
51
|
+
|
|
52
|
+
Available on [GitHub](https://github.com/renault-digital/bash-base),
|
|
53
|
+
[NPM](https://www.npmjs.com/package/@renault-digital/bash-base), and
|
|
54
|
+
[Docker Hub](https://hub.docker.com/r/renaultdigital/bash-base).
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Bash and zsh compatibility
|
|
58
|
+
|
|
59
|
+
The reusable functions in `src/` can be sourced by both **Bash** and **zsh**.
|
|
60
|
+
This matters on macOS, where zsh is the default interactive shell: `source
|
|
61
|
+
bash-base` is interpreted by the current shell, so the library itself must not
|
|
62
|
+
rely on hidden Bash-only syntax.
|
|
63
|
+
|
|
64
|
+
Existing Bash scripts and the Bash ShellSpec regression suite remain supported.
|
|
65
|
+
A separate dual-shell compatibility gate runs the same core behavior under Bash
|
|
66
|
+
and zsh.
|
|
67
|
+
|
|
68
|
+
See [Bash and zsh compatibility](docs/bash-zsh-compatibility.md) for the exact
|
|
69
|
+
contract, array portability boundary and test model.
|
|
22
70
|
|
|
23
71
|
|
|
24
72
|
## Test coverage report
|
|
25
|
-
|
|
73
|
+
|
|
74
|
+
The `coverage-macos` CI job requires **100% of the measurable `src/*.sh` lines**
|
|
75
|
+
to be covered by the validated union of Bash 3.2, Bash 5+, zsh and TTY runs on
|
|
76
|
+
one source revision. This is **union line coverage**, not 100% coverage in each
|
|
77
|
+
shell or a claim of complete branch/input coverage.
|
|
78
|
+
|
|
79
|
+
Only that validated union is uploaded to Codecov. Invalid reports are rejected;
|
|
80
|
+
a valid result below 100% is still reported, while the strict CI gate fails.
|
|
81
|
+
The badge shows Codecov's latest processed result for `master`, not a hard-coded
|
|
82
|
+
percentage. Click the tree below for file and line details, and check the commit
|
|
83
|
+
SHA when comparing it with CI. Processing delays or a missing upload may leave
|
|
84
|
+
an older result visible.
|
|
85
|
+
|
|
86
|
+
[](https://app.codecov.io/gh/renault-digital/bash-base/tree/master/src)
|
|
87
|
+
|
|
88
|
+
See the [CI test matrix](docs/coverage.md#ci-test-matrix) for runner, interpreter,
|
|
89
|
+
test scope and report destinations.
|
|
90
|
+
|
|
91
|
+
See [coverage collection, validation and reporting](docs/coverage.md) for the
|
|
92
|
+
report contract, authentication setup and troubleshooting. CI also retains the
|
|
93
|
+
raw reports, source hashes and logs in the `strict-macos-coverage` artifact.
|
|
26
94
|
|
|
27
95
|
|
|
28
96
|
## Quick start
|
|
@@ -53,6 +121,11 @@ Run it:
|
|
|
53
121
|
|
|
54
122
|
## Installation
|
|
55
123
|
|
|
124
|
+
For reproducible or offline workflows, prefer a reviewed, fixed-version local
|
|
125
|
+
copy. The methods below have different network and update behavior; read the
|
|
126
|
+
Web installer and direct GitHub import notes before choosing a loading method.
|
|
127
|
+
A remote-loading example is not an offline configuration.
|
|
128
|
+
|
|
56
129
|
#### 1. Import from [docker hub](https://hub.docker.com/r/renaultdigital/bash-base)
|
|
57
130
|
|
|
58
131
|
```bash
|
|
@@ -228,11 +301,19 @@ See [reference](docs/references.md)
|
|
|
228
301
|
See [example](example) folder, including the use case of <mark>**[Makefile](example/Makefile)**</mark>
|
|
229
302
|
|
|
230
303
|
## Specfile (test file)
|
|
231
|
-
See [spec](spec) folder
|
|
304
|
+
See [spec](spec) folder. Run `npm test` to execute the Bash/zsh compatibility gate followed by the existing Bash ShellSpec regression suite.
|
|
232
305
|
|
|
233
306
|
## Latest Update
|
|
234
307
|
See [change log](CHANGELOG.md)
|
|
235
308
|
|
|
309
|
+
## Roadmap
|
|
310
|
+
|
|
311
|
+
See the [project roadmap](docs/roadmap.md) for prioritized investigation and
|
|
312
|
+
future evolution of command composition, API contracts, shell portability,
|
|
313
|
+
security, testing and distribution. The roadmap is not a commitment to ship
|
|
314
|
+
particular features or versions. New proposals follow the
|
|
315
|
+
[design principles](docs/design-principles.md).
|
|
316
|
+
|
|
236
317
|
## Contributing
|
|
237
318
|
See [How to contribute](CONTRIBUTING.md)
|
|
238
319
|
|