@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/docs/references.md
CHANGED
|
@@ -2,74 +2,128 @@
|
|
|
2
2
|
|
|
3
3
|
### Functions:
|
|
4
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
|
-
-
|
|
5
|
+
-args_confirm
|
|
6
|
+
-args_print
|
|
7
|
+
-args_parse
|
|
8
|
+
-args_valid_or_select
|
|
9
|
+
-args_valid_or_select_pipe
|
|
10
|
+
-args_valid_or_select_args
|
|
11
|
+
-args_valid_or_read
|
|
12
|
+
-args_valid_or_default
|
|
13
|
+
-array_join
|
|
14
|
+
-array_describe
|
|
15
|
+
-array_from_describe
|
|
16
|
+
-array_contains
|
|
17
|
+
-array_in
|
|
18
|
+
-array_sort
|
|
19
|
+
-array_sort_distinct
|
|
20
|
+
-array_length
|
|
21
|
+
-array_reset_index
|
|
22
|
+
-array_equals
|
|
23
|
+
-array_intersection
|
|
24
|
+
-array_subtract
|
|
25
|
+
-array_union
|
|
26
|
+
-array_append
|
|
27
|
+
-array_remove
|
|
28
|
+
-array_clone
|
|
29
|
+
-array_map
|
|
30
|
+
-array_filter
|
|
31
|
+
-doc_lint_script_comment
|
|
32
|
+
-doc_comment_to_markdown
|
|
33
|
+
-print_debug
|
|
34
|
+
-print_info
|
|
35
|
+
-print_warn
|
|
36
|
+
-print_error
|
|
37
|
+
-print_success
|
|
38
|
+
-print_args
|
|
39
|
+
-print_header
|
|
40
|
+
-prc_filter_by_port
|
|
41
|
+
-prc_kill_by_port
|
|
42
|
+
-prc_filter_by_cmd
|
|
43
|
+
-prc_kill_by_cmd
|
|
44
|
+
-reflect_nth_arg
|
|
45
|
+
-reflect_get__definition
|
|
46
|
+
-reflect__names_of_file
|
|
47
|
+
-reflect__definitions_of_file
|
|
48
|
+
-reflect_search_
|
|
49
|
+
-reflect_search_variable
|
|
50
|
+
-string_trim
|
|
51
|
+
-string_repeat
|
|
52
|
+
-string_length
|
|
53
|
+
-string_is_empty
|
|
54
|
+
-string_revert
|
|
55
|
+
-string_upper
|
|
56
|
+
-string_lower
|
|
57
|
+
-string_upper_first
|
|
58
|
+
-string_sub
|
|
59
|
+
-string_match
|
|
60
|
+
-escape_sed
|
|
61
|
+
-string_replace
|
|
62
|
+
-string_replace_regex
|
|
63
|
+
-string_index_first
|
|
64
|
+
-string_before_first
|
|
65
|
+
-string_after_first
|
|
66
|
+
-string_split_to_array
|
|
67
|
+
-string_pick_to_array
|
|
68
|
+
-stop_if_failed
|
|
69
|
+
-confirm_to_continue
|
|
70
|
+
-wait_for
|
|
71
|
+
-declare_heredoc
|
|
70
72
|
|
|
71
73
|
### Usage:
|
|
72
74
|
|
|
75
|
+
##### NAME
|
|
76
|
+
aliases need different non-interactive expansion rules in Bash and zsh, while
|
|
77
|
+
functions work identically when this library is sourced by either shell.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
##### NAME
|
|
82
|
+
args_confirm -- show the name and value of variables, and continue execute if args_confirm by user, or exit if not
|
|
83
|
+
|
|
84
|
+
##### SYNOPSIS
|
|
85
|
+
```
|
|
86
|
+
args_confirm variableName...
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
##### DESCRIPTION
|
|
90
|
+
- **variableName...** some existed variable names to show its value
|
|
91
|
+
|
|
92
|
+
##### EXAMPLES
|
|
93
|
+
```
|
|
94
|
+
a="correct value"
|
|
95
|
+
b="wrong value"
|
|
96
|
+
args_confirm a b
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
##### SEE_ALSO
|
|
100
|
+
args_print, stop_if_failed
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
##### NAME
|
|
105
|
+
args_print -- if LOG_LEVEL<=$LOG_LEVEL_WARN, show the name and value of variables
|
|
106
|
+
|
|
107
|
+
##### SYNOPSIS
|
|
108
|
+
```
|
|
109
|
+
args_print variableName...
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
##### DESCRIPTION
|
|
113
|
+
- **variableName...** some existed variable names to show its value
|
|
114
|
+
|
|
115
|
+
##### EXAMPLES
|
|
116
|
+
```
|
|
117
|
+
var1="value 1"
|
|
118
|
+
var2="value 2"
|
|
119
|
+
args_print var1 var2
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
##### SEE_ALSO
|
|
123
|
+
print_header, print_error, print_success, print_warn, print_info, print_debug
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
73
127
|
##### NAME
|
|
74
128
|
args_parse -- parse the script argument values to positional variable names, process firstly the optional param help(-h) / quiet(-q) if existed
|
|
75
129
|
|
|
@@ -244,7 +298,7 @@ string_split_to_array, array_describe, array_from_describe
|
|
|
244
298
|
---
|
|
245
299
|
|
|
246
300
|
##### NAME
|
|
247
|
-
array_describe -- convert the array to its string representation
|
|
301
|
+
array_describe -- convert the array to its shell-native string representation
|
|
248
302
|
|
|
249
303
|
##### SYNOPSIS
|
|
250
304
|
```
|
|
@@ -401,7 +455,7 @@ array_length myArray ==> 3
|
|
|
401
455
|
---
|
|
402
456
|
|
|
403
457
|
##### NAME
|
|
404
|
-
array_reset_index -- reset
|
|
458
|
+
array_reset_index -- reset indexes to the shell-native contiguous sequence, save the result to original variable name
|
|
405
459
|
|
|
406
460
|
##### SYNOPSIS
|
|
407
461
|
```
|
|
@@ -413,7 +467,7 @@ array_reset_index arrayVarName
|
|
|
413
467
|
|
|
414
468
|
##### EXAMPLES
|
|
415
469
|
```
|
|
416
|
-
myArray=([2]='a' [5]='c' [11]='dd')
|
|
470
|
+
Bash example: myArray=([2]='a' [5]='c' [11]='dd')
|
|
417
471
|
array_reset_index myArray ==> ([0]='a' [1]='c' [2]='dd')
|
|
418
472
|
```
|
|
419
473
|
|
package/docs/roadmap.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Bash-base roadmap
|
|
2
|
+
|
|
3
|
+
> **Status:** Planning document; last reviewed 2026-10-16. Priorities and status
|
|
4
|
+
> notes describe the known project state at that review, not a guarantee of
|
|
5
|
+
> present CI or release status. Check current GitHub issues, pull requests,
|
|
6
|
+
> workflow runs and published artifacts before acting.
|
|
7
|
+
|
|
8
|
+
## Purpose and scope
|
|
9
|
+
|
|
10
|
+
Bash-base aims to make **command-oriented Bash and zsh programming more reliable,
|
|
11
|
+
understandable and composable**. Reusable higher-level helpers should reduce
|
|
12
|
+
repeated searching, comparison, experimentation, verification and maintenance.
|
|
13
|
+
String and array operations support argument management, output transformation
|
|
14
|
+
and automation logic; implementing a general-purpose data-processing language
|
|
15
|
+
is not the project's goal.
|
|
16
|
+
|
|
17
|
+
This roadmap identifies problems to investigate, their relative priorities and
|
|
18
|
+
what evidence would justify calling the work complete. It is **not** a promise
|
|
19
|
+
that every proposed API will be implemented, a release schedule, or a statement
|
|
20
|
+
that unimplemented helpers are already available.
|
|
21
|
+
|
|
22
|
+
Read [design principles](design-principles.md) for lasting rules,
|
|
23
|
+
[Bash/zsh compatibility](bash-zsh-compatibility.md) for the currently documented
|
|
24
|
+
portability contract, [coverage and the CI test matrix](coverage.md) for actual
|
|
25
|
+
test scope, and [CONTRIBUTING](../CONTRIBUTING.md) for proposal and review
|
|
26
|
+
requirements. The [generated API reference](references.md) and source comments,
|
|
27
|
+
not this roadmap, describe shipped APIs.
|
|
28
|
+
|
|
29
|
+
## How priorities and status work
|
|
30
|
+
|
|
31
|
+
| Priority | Meaning |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| **P0 — Reliability and foundations** | Protect current consumers, close release/security risks and establish contracts needed before safely expanding APIs. |
|
|
34
|
+
| **P1 — Coherent evolution** | Improve composability, data semantics, deployment experience and testing after their dependencies are understood. |
|
|
35
|
+
| **P2 — Candidate capabilities** | Investigate useful new helpers only when real recurring use cases justify them. |
|
|
36
|
+
|
|
37
|
+
Possible status values are **Proposed**, **Under investigation**, **Planned**,
|
|
38
|
+
**In progress**, **Blocked** and **Completed**. An item's presence or P-level
|
|
39
|
+
**does not authorize implementation**. Keep statuses and evidence in focused
|
|
40
|
+
GitHub issues and pull requests; update this document when the direction,
|
|
41
|
+
priority or acceptance criteria meaningfully change. Do not invent dates or
|
|
42
|
+
promise a particular release number before scope and risks are reviewed.
|
|
43
|
+
|
|
44
|
+
## P0 — Reliability, release integrity and API foundations
|
|
45
|
+
|
|
46
|
+
### P0.1 Complete and verify the release chain
|
|
47
|
+
|
|
48
|
+
**Status (2026-10-16): In progress.** The GitHub Actions to npm OIDC token
|
|
49
|
+
exchange was observed to succeed. The first end-to-end publication was not
|
|
50
|
+
completed in the observed run: release Git push was blocked by a local Husky
|
|
51
|
+
`pre-push` hook in a job without zsh. Treat this as a release-workflow issue;
|
|
52
|
+
do not reintroduce a long-lived npm publishing token or bypass existing quality
|
|
53
|
+
gates. Current results and fixes must be checked in the relevant CI runs.
|
|
54
|
+
|
|
55
|
+
Work to investigate and verify:
|
|
56
|
+
|
|
57
|
+
- Keep npm Trusted Publishing matched to the authorized GitHub repository and
|
|
58
|
+
release workflow, with narrowly scoped `id-token: write` on trusted release
|
|
59
|
+
jobs. Validate actual publication, not only credential exchange or dry-run.
|
|
60
|
+
- Keep GitHub Release and Docker authentication separate from npm OIDC. Avoid
|
|
61
|
+
re-running developer-local Git hooks in release jobs after required CI gates,
|
|
62
|
+
without disabling those hooks for contributors.
|
|
63
|
+
- Verify npm package version, Git tags, generated bundle, GitHub Release and
|
|
64
|
+
Docker tags/images represent the intended source and release. Investigate the
|
|
65
|
+
previously observed mismatch between the npm published version and the latest
|
|
66
|
+
Git tag instead of assuming they were always synchronized.
|
|
67
|
+
- Review release-trigger rules and side effects: documentation and CI commits
|
|
68
|
+
may currently cause a patch release. Preserve intended behavior until a
|
|
69
|
+
separate, reviewed change establishes a new policy.
|
|
70
|
+
- After a successful trusted publish, review restrictive package publishing
|
|
71
|
+
access and retire obsolete npm tokens without removing credentials needed by
|
|
72
|
+
other release destinations.
|
|
73
|
+
|
|
74
|
+
**Acceptance:** A real authorized `master` release completes with the required
|
|
75
|
+
lint, compatibility, regression and strict coverage jobs passing; npm, GitHub
|
|
76
|
+
and Docker artifacts are checked against the intended tag/source; the npm
|
|
77
|
+
Trusted Publisher is validated; no legacy `NPM_TOKEN` is needed by npm publish.
|
|
78
|
+
|
|
79
|
+
### P0.2 Security and compatibility audit of existing code
|
|
80
|
+
|
|
81
|
+
**Status: Planned; findings require fresh source review.**
|
|
82
|
+
|
|
83
|
+
- Audit `eval`, dynamic variable names/references, command-string construction,
|
|
84
|
+
argument quoting, glob expansion, external input and re-interpretation of data
|
|
85
|
+
as Shell code. Distinguish APIs intentionally accepting *trusted code* from
|
|
86
|
+
APIs accepting ordinary data.
|
|
87
|
+
- Audit process selection/termination (especially `prc_filter_by_cmd` and
|
|
88
|
+
`prc_kill_by_cmd`) for ambiguous matches, accidental termination, exit-state
|
|
89
|
+
handling and potential safer PID-based alternatives.
|
|
90
|
+
- Audit `source`-time and repeated-source effects on caller variables, `IFS`,
|
|
91
|
+
options, traps, current directory, terminal interaction and stdout/stderr.
|
|
92
|
+
- Check historical executable-mode changes on `src/*.sh` against actual intended
|
|
93
|
+
use. Sourcing a file does not require the executable bit; whether direct
|
|
94
|
+
execution is a supported contract must be verified before changing modes.
|
|
95
|
+
- Audit npm vulnerabilities using a current dependency tree and threat model;
|
|
96
|
+
distinguish development/build-only dependencies from runtime exposure.
|
|
97
|
+
Previous `npm ci` warnings are a historical finding, not a current count.
|
|
98
|
+
|
|
99
|
+
**Acceptance:** Findings have reproducible evidence and risk classification;
|
|
100
|
+
changes preserve existing Bash and documented zsh behavior unless deliberate
|
|
101
|
+
migration is approved; regression and adversarial-input tests cover fixes. Do
|
|
102
|
+
not remove `eval` indiscriminately or use `npm audit fix --force` as a shortcut.
|
|
103
|
+
|
|
104
|
+
### P0.3 Define a consistent public API contract
|
|
105
|
+
|
|
106
|
+
**Status: Planned. Design guidance exists; per-helper review remains.**
|
|
107
|
+
|
|
108
|
+
Define and document, for new public APIs and each reviewed legacy API:
|
|
109
|
+
|
|
110
|
+
| Contract area | Required decisions |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| Input | Positional parameters, stdin, named variables; accepted identifiers and record boundaries. |
|
|
113
|
+
| Output | stdout, named destination, in-place change or other side effect; output suitable for composition. |
|
|
114
|
+
| Outcomes | How success, false predicates, empty results, invalid inputs and command failures differ. |
|
|
115
|
+
| Data | Ordering, duplicates, empty elements, whitespace, newlines, encoding limitations and serialization domain. |
|
|
116
|
+
| Execution | External processes, prompts, timeouts, cleanup, cwd, traps, variables and other caller-state changes. |
|
|
117
|
+
| Portability | Tested Shell versions and GNU/BSD command requirements; explicitly documented exceptions. |
|
|
118
|
+
|
|
119
|
+
**Acceptance:** A reviewed, example-backed contract template is available and
|
|
120
|
+
applied to the first representative String, Array, Argument and Process helpers;
|
|
121
|
+
contract tests prove relevant boundary behavior. Existing undocumented quirks
|
|
122
|
+
are catalogued before redesign. New guidelines **do not retroactively change**
|
|
123
|
+
legacy API semantics.
|
|
124
|
+
|
|
125
|
+
### P0.4 Preserve trustworthy test and coverage gates
|
|
126
|
+
|
|
127
|
+
**Status: Established gates; continued assurance required.**
|
|
128
|
+
|
|
129
|
+
- Preserve the Bash regression suite, Bash/zsh compatibility checks and the
|
|
130
|
+
macOS Bash 3.2 / Bash 5+ / zsh / interactive TTY coverage collection.
|
|
131
|
+
- Keep the **100% union of measurable source lines** as a mandatory CI gate.
|
|
132
|
+
This does **not** mean each Shell individually has 100% coverage, or that all
|
|
133
|
+
branches, inputs, OS combinations or security properties have been tested.
|
|
134
|
+
- Ensure that Codecov displays the validated report for the correct source
|
|
135
|
+
revision, and that report-export or upload failures cannot silently create a
|
|
136
|
+
misleading green result. Preserve diagnostics for failures.
|
|
137
|
+
- Add boundary, negative-case, quoting, failure-propagation and caller-state
|
|
138
|
+
tests where risk warrants them. Keep test selectors and the
|
|
139
|
+
[CI test matrix](coverage.md#ci-test-matrix) synchronized.
|
|
140
|
+
|
|
141
|
+
**Acceptance:** Mandatory CI gates fail on a regression or a real coverage
|
|
142
|
+
shortfall; reports and source identity are verifiable; neither exclusions,
|
|
143
|
+
synthetic hits nor weakened assertions are used to satisfy a coverage number.
|
|
144
|
+
|
|
145
|
+
## P1 — Coherent abstractions and adoption
|
|
146
|
+
|
|
147
|
+
### P1.1 Clarify String / Array / List / Set semantics
|
|
148
|
+
|
|
149
|
+
**Status: Planned (design before expansion).**
|
|
150
|
+
|
|
151
|
+
- Distinguish a String from a Shell-native Array, a List (ordered, duplicates
|
|
152
|
+
allowed) and a Set (unique elements; traversal order must be specified).
|
|
153
|
+
- Audit the real behavior of existing `array_*` functions, especially union,
|
|
154
|
+
intersection, duplicates and ordering. Do not rename or change them just
|
|
155
|
+
because a new conceptual model is clearer.
|
|
156
|
+
- Decide whether distinct `list_*` or `set_*` APIs solve real command-input or
|
|
157
|
+
command-output workflows; avoid adding an entire family for symmetry alone.
|
|
158
|
+
- Verify empty elements, spaces, literal wildcards, newline-containing values,
|
|
159
|
+
shell indexing and serialization/restore boundaries in supported Shells.
|
|
160
|
+
|
|
161
|
+
**Acceptance:** A documented semantic model, representative composition
|
|
162
|
+
examples, compatibility analysis and cross-Shell boundary tests precede any
|
|
163
|
+
new public type family.
|
|
164
|
+
|
|
165
|
+
### P1.2 Investigate a Map API
|
|
166
|
+
|
|
167
|
+
**Status: Under investigation; not an implemented feature.**
|
|
168
|
+
|
|
169
|
+
Potential uses include options, configuration and key/value associations
|
|
170
|
+
between system commands. Start with a contract rather than function names:
|
|
171
|
+
|
|
172
|
+
- Key and value domain; empty values versus missing keys; duplicate assignment.
|
|
173
|
+
- Lookup, insertion/removal and iteration semantics; deterministic ordering
|
|
174
|
+
only if explicitly promised; memory and performance constraints.
|
|
175
|
+
- Serialization, newlines and unsafe code/data boundaries.
|
|
176
|
+
- A Bash 3.2-compatible representation (it lacks native associative arrays),
|
|
177
|
+
and any Bash 5+/zsh optimization that preserves the same public contract.
|
|
178
|
+
|
|
179
|
+
**Acceptance:** Demonstrate a recurring use case that existing built-ins,
|
|
180
|
+
helpers or tools do not solve adequately; compare representations and costs;
|
|
181
|
+
approve an API contract and test model before implementation. A proposal can
|
|
182
|
+
be rejected if complexity outweighs command-composition value.
|
|
183
|
+
|
|
184
|
+
### P1.3 Improve module loading and namespacing
|
|
185
|
+
|
|
186
|
+
**Status: Proposed.**
|
|
187
|
+
|
|
188
|
+
- Investigate optional `bb_*` namespaced entry points to reduce function-name
|
|
189
|
+
collisions. Keep current public names working unless a separately planned,
|
|
190
|
+
properly versioned migration is approved.
|
|
191
|
+
- Investigate selective module loading with explicit module dependencies,
|
|
192
|
+
idempotence and well-defined `source` effects. Simply splitting files is not
|
|
193
|
+
proof of independent modules.
|
|
194
|
+
- Prefer a migration/adoption story with tangible benefit over a broad,
|
|
195
|
+
mechanical rename or a large framework layer.
|
|
196
|
+
|
|
197
|
+
**Acceptance:** Dependency and state model documented; current full-library
|
|
198
|
+
loading remains compatible; realistic scripts validate both old and new usage.
|
|
199
|
+
|
|
200
|
+
### P1.4 Strengthen fixed-version and offline-first distribution
|
|
201
|
+
|
|
202
|
+
**Status: Proposed enhancements to existing distribution.**
|
|
203
|
+
|
|
204
|
+
The build **already generates a single-file** `bin/bash-base`; do not propose
|
|
205
|
+
adding that existing feature a second time. Instead:
|
|
206
|
+
|
|
207
|
+
- Make pinned/local/offline usage clear and straightforward, with examples
|
|
208
|
+
for GitHub, npm, Docker and bundled artifacts that state when network access
|
|
209
|
+
occurs. Never imply that `source <(curl ...)` works offline.
|
|
210
|
+
- Evaluate module vendoring or focused bundling only when it lowers setup and
|
|
211
|
+
maintenance costs without changing behavior.
|
|
212
|
+
- Verify runtime requirements separately from npm/Docker tools used for build,
|
|
213
|
+
CI or distribution. Check version provenance and reproducibility where useful.
|
|
214
|
+
|
|
215
|
+
**Acceptance:** A documented, reproducible installation and loading path can
|
|
216
|
+
be followed with a pinned artifact after initial acquisition, without requiring
|
|
217
|
+
Node.js or Docker merely to execute the already-provided Shell library.
|
|
218
|
+
|
|
219
|
+
### P1.5 Improve examples and user-facing documentation
|
|
220
|
+
|
|
221
|
+
**Status: Planned, incremental.**
|
|
222
|
+
|
|
223
|
+
- Update the README Quick Start and API navigation to match current supported
|
|
224
|
+
Bash/zsh behavior and distinguish online shortcuts from pinned local usage.
|
|
225
|
+
- Add complete realistic examples that orchestrate Git, SSH, Docker or system
|
|
226
|
+
commands with safe argument boundaries, outputs, failures and cleanup.
|
|
227
|
+
- Keep generated references derived from source comments; do not hand-edit
|
|
228
|
+
`docs/references.md`, `bin/` or man pages outside their generation workflow.
|
|
229
|
+
- Track reproducible feedback and real usage rather than treating Stars,
|
|
230
|
+
downloads or function count as proxies for correctness or adoption.
|
|
231
|
+
|
|
232
|
+
**Acceptance:** Examples execute in declared environments; links and generated
|
|
233
|
+
artifacts correspond to the implementation; user feedback informs prioritization.
|
|
234
|
+
|
|
235
|
+
## P2 — Problem-driven helper candidates (not commitments)
|
|
236
|
+
|
|
237
|
+
Investigate a candidate **only when** there is a concrete and recurring
|
|
238
|
+
command-composition cost and a contract can be made clear. Priority within this
|
|
239
|
+
table is intentionally not assigned in advance.
|
|
240
|
+
|
|
241
|
+
| Candidate | Problem worth investigating | Main risk / contract question |
|
|
242
|
+
| --- | --- | --- |
|
|
243
|
+
| Bounded `retry` | Transient failures of appropriate external commands | Retry safety/idempotence, wait policy, exit status, stdout/stderr and cancellation. |
|
|
244
|
+
| Portable `timeout` | Commands or children that hang | Process groups, signal propagation, cleanup and GNU/BSD differences. |
|
|
245
|
+
| Cleanup registration | Consistent temporary-file/process cleanup | Trap ownership, nested/early exits and caller-state changes. |
|
|
246
|
+
| Dependency checks | Missing external programs or incompatible tool variants | Clear diagnostics and optional/versioned requirements. |
|
|
247
|
+
| Portable path resolution | GNU/BSD differences in paths and symlinks | Physical/logical paths, missing targets and special characters. |
|
|
248
|
+
| Secure temporary-file helpers | Cross-platform safe file/directory creation | Races, permissions, lifetime and cleanup contract. |
|
|
249
|
+
| Argument/output adapters | Prevent splitting, globbing and unsafe record decoding | Preserve boundaries, empty values and newlines; no fake lossless text format. |
|
|
250
|
+
| Structured logging | Consistent diagnostic output for automation | stdout/stderr ownership, optional external dependencies and formatting. |
|
|
251
|
+
| Safer process APIs | Replace ambiguous process-name matching where appropriate | PID identity, permissions, dry-run and accidental termination. |
|
|
252
|
+
|
|
253
|
+
No candidate name above should be treated as an existing Bash-base API. A
|
|
254
|
+
small example, clearer documentation or an established external utility may be
|
|
255
|
+
preferable to implementing a wrapper.
|
|
256
|
+
|
|
257
|
+
## Backward compatibility and release strategy
|
|
258
|
+
|
|
259
|
+
The default is to **preserve the v2.x public Bash behavior and documented zsh
|
|
260
|
+
support**. Prefer new explicit contracts and additive, narrowly scoped APIs
|
|
261
|
+
over silent changes to old names or outputs. For any breaking change, document
|
|
262
|
+
consumer impact, alternatives, migration steps and why a major release is
|
|
263
|
+
necessary. A hypothetical v3 is not a scheduled deliverable.
|
|
264
|
+
|
|
265
|
+
Do not expand the project into a full object system, general JSON/YAML engine,
|
|
266
|
+
all-POSIX-Shell portability layer or a Python-equivalent standard library
|
|
267
|
+
without separately demonstrated command-oriented need. High-level abstraction
|
|
268
|
+
should hide incidental complexity, **not meaningful errors or side effects**.
|
|
269
|
+
|
|
270
|
+
## How an item becomes work — and how work is accepted
|
|
271
|
+
|
|
272
|
+
1. **Describe the pain.** Provide a real script or task, the repetitive research
|
|
273
|
+
and verification burden, and the commands/data boundaries involved.
|
|
274
|
+
2. **Compare alternatives.** Check built-ins, existing helpers, external tools,
|
|
275
|
+
example-only solutions and their deployment costs.
|
|
276
|
+
3. **Define the contract.** Decide inputs, outputs, return states, side effects,
|
|
277
|
+
portability limits, versioning and a realistic composition example.
|
|
278
|
+
4. **Validate the change.** Add behavior and failure tests in relevant Shells,
|
|
279
|
+
check caller state and preserve the existing required CI and 100% line-union
|
|
280
|
+
gate. Coverage is evidence, not proof of total correctness.
|
|
281
|
+
5. **Review net maintenance value.** Accept only when expected time/risk savings
|
|
282
|
+
justify implementation, learning and long-term support cost.
|
|
283
|
+
|
|
284
|
+
Create a focused [GitHub issue](https://github.com/renault-digital/bash-base/issues)
|
|
285
|
+
for an approved investigation or proposed task, linking the appropriate
|
|
286
|
+
acceptance evidence. Use [pull requests](https://github.com/renault-digital/bash-base/pulls)
|
|
287
|
+
to track actual implementation and verification; don't mark an item completed
|
|
288
|
+
because a document or proposal has been written. Re-review this roadmap after
|
|
289
|
+
material changes rather than treating priorities or estimates as permanent.
|
package/man/bash-base.1
CHANGED
|
@@ -4,6 +4,72 @@
|
|
|
4
4
|
.hy
|
|
5
5
|
.SS NAME
|
|
6
6
|
.PP
|
|
7
|
+
aliases need different non-interactive expansion rules in Bash and zsh,
|
|
8
|
+
while functions work identically when this library is sourced by either
|
|
9
|
+
shell.
|
|
10
|
+
.PP
|
|
11
|
+
* * * * *
|
|
12
|
+
.SS NAME
|
|
13
|
+
.PP
|
|
14
|
+
args_confirm \[en] show the name and value of variables, and continue
|
|
15
|
+
execute if args_confirm by user, or exit if not
|
|
16
|
+
.SS SYNOPSIS
|
|
17
|
+
.IP
|
|
18
|
+
.nf
|
|
19
|
+
\f[C]
|
|
20
|
+
args_confirm variableName...
|
|
21
|
+
\f[R]
|
|
22
|
+
.fi
|
|
23
|
+
.SS DESCRIPTION
|
|
24
|
+
.IP \[bu] 2
|
|
25
|
+
\f[B]variableName\&...\f[R] some existed variable names to show its
|
|
26
|
+
value
|
|
27
|
+
.SS EXAMPLES
|
|
28
|
+
.IP
|
|
29
|
+
.nf
|
|
30
|
+
\f[C]
|
|
31
|
+
a=\[dq]correct value\[dq]
|
|
32
|
+
b=\[dq]wrong value\[dq]
|
|
33
|
+
args_confirm a b
|
|
34
|
+
\f[R]
|
|
35
|
+
.fi
|
|
36
|
+
.SS SEE_ALSO
|
|
37
|
+
.PP
|
|
38
|
+
args_print, stop_if_failed
|
|
39
|
+
.PP
|
|
40
|
+
* * * * *
|
|
41
|
+
.SS NAME
|
|
42
|
+
.PP
|
|
43
|
+
args_print \[en] if LOG_LEVEL<=$LOG_LEVEL_WARN, show the name and value
|
|
44
|
+
of variables
|
|
45
|
+
.SS SYNOPSIS
|
|
46
|
+
.IP
|
|
47
|
+
.nf
|
|
48
|
+
\f[C]
|
|
49
|
+
args_print variableName...
|
|
50
|
+
\f[R]
|
|
51
|
+
.fi
|
|
52
|
+
.SS DESCRIPTION
|
|
53
|
+
.IP \[bu] 2
|
|
54
|
+
\f[B]variableName\&...\f[R] some existed variable names to show its
|
|
55
|
+
value
|
|
56
|
+
.SS EXAMPLES
|
|
57
|
+
.IP
|
|
58
|
+
.nf
|
|
59
|
+
\f[C]
|
|
60
|
+
var1=\[dq]value 1\[dq]
|
|
61
|
+
var2=\[dq]value 2\[dq]
|
|
62
|
+
args_print var1 var2
|
|
63
|
+
\f[R]
|
|
64
|
+
.fi
|
|
65
|
+
.SS SEE_ALSO
|
|
66
|
+
.PP
|
|
67
|
+
print_header, print_error, print_success, print_warn, print_info,
|
|
68
|
+
print_debug
|
|
69
|
+
.PP
|
|
70
|
+
* * * * *
|
|
71
|
+
.SS NAME
|
|
72
|
+
.PP
|
|
7
73
|
args_parse \[en] parse the script argument values to positional variable
|
|
8
74
|
names, process firstly the optional param help(-h) / quiet(-q) if
|
|
9
75
|
existed
|
|
@@ -247,7 +313,8 @@ string_split_to_array, array_describe, array_from_describe
|
|
|
247
313
|
* * * * *
|
|
248
314
|
.SS NAME
|
|
249
315
|
.PP
|
|
250
|
-
array_describe \[en] convert the array to its string
|
|
316
|
+
array_describe \[en] convert the array to its shell-native string
|
|
317
|
+
representation
|
|
251
318
|
.SS SYNOPSIS
|
|
252
319
|
.IP
|
|
253
320
|
.nf
|
|
@@ -443,8 +510,8 @@ array_length myArray ==> 3
|
|
|
443
510
|
* * * * *
|
|
444
511
|
.SS NAME
|
|
445
512
|
.PP
|
|
446
|
-
array_reset_index \[en] reset
|
|
447
|
-
|
|
513
|
+
array_reset_index \[en] reset indexes to the shell-native contiguous
|
|
514
|
+
sequence, save the result to original variable name
|
|
448
515
|
.SS SYNOPSIS
|
|
449
516
|
.IP
|
|
450
517
|
.nf
|
|
@@ -459,7 +526,7 @@ array_reset_index arrayVarName
|
|
|
459
526
|
.IP
|
|
460
527
|
.nf
|
|
461
528
|
\f[C]
|
|
462
|
-
myArray=([2]=\[aq]a\[aq] [5]=\[aq]c\[aq] [11]=\[aq]dd\[aq])
|
|
529
|
+
Bash example: myArray=([2]=\[aq]a\[aq] [5]=\[aq]c\[aq] [11]=\[aq]dd\[aq])
|
|
463
530
|
array_reset_index myArray ==> ([0]=\[aq]a\[aq] [1]=\[aq]c\[aq] [2]=\[aq]dd\[aq])
|
|
464
531
|
\f[R]
|
|
465
532
|
.fi
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renault-digital/bash-base",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"description": "Reusable Bash/zsh utilities for reliable command composition and automation.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"CONTRIBUTING.md",
|
|
13
13
|
"package-lock.json",
|
|
14
14
|
"scripts/test.sh",
|
|
15
|
+
"scripts/test-shell-compat.sh",
|
|
15
16
|
"src/",
|
|
16
17
|
"bin/",
|
|
17
18
|
"docs/",
|
|
@@ -65,6 +66,6 @@
|
|
|
65
66
|
"cz-conventional-changelog": "^3.3.0",
|
|
66
67
|
"husky": "^9.1.7",
|
|
67
68
|
"merge": ">=2.1.1",
|
|
68
|
-
"semantic-release": "
|
|
69
|
+
"semantic-release": "25.0.9"
|
|
69
70
|
}
|
|
70
71
|
}
|