Skip to content

Commit a3a8a8a

Browse files
committed
bash.bash: require bash 5.1+ on suse
versions.md: document for 5.3, and note a 5.1 bugfix
1 parent 0a82ced commit a3a8a8a

File tree

2 files changed

+130
-16
lines changed

2 files changed

+130
-16
lines changed

docs/bash/versions.md

Lines changed: 116 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ From changelog:
4949
- Introduces `mapfile`, as well as the `readarray` alias for `mapfile`.
5050
- Introduces `${var^}` and `${var,}` for uppercase and lowercase conversions.
5151

52-
Changelog:
52+
<details>
53+
<summary>Changelog:</summary>
5354

5455
> This document details the changes between this version, `bash-4.0-release`,
5556
> and the previous version, `bash-4.0-rc1`.
5657
>
5758
> a. `readarray` is now a synonym for `mapfile`.
5859
59-
> This document details the changes between this version, `bash-4.0-alpha`, and the previous version, `bash-3.2-release`.
60+
> This document details the changes between this version, `bash-4.0-alpha`, and the previous version,`bash-3.2-release`.
6061
>
6162
> p. The `read` builtin has a new `-i` option which inserts text into the reply buffer when using readline.
6263
>
@@ -70,6 +71,8 @@ Changelog:
7071
>
7172
> hh. There are new case-modifying word expansions: uppercase `(^[^])` and lowercase `(,[,])`. They can work on either the first character or array element, or globally. They accept an optional shell pattern that determines which characters to modify. There is an optionally-configured feature to include capitalization operators.
7273
74+
</details>
75+
7376
## bash v4.1
7477

7578
> [!CAUTION]
@@ -88,7 +91,8 @@ From changelog:
8891
- Introduces `BASH_XTRACEFD` for redirecting xtrace output to a file descriptor.
8992
- Introduces `{fd}` syntax for opening unused file descriptors.
9093

91-
Changelog:
94+
<details>
95+
<summary>Changelog:</summary>
9296

9397
> This document details the changes between this version, `bash-4.1-alpha`, and the previous version, `bash-4.0-release`.
9498
>
@@ -98,6 +102,8 @@ Changelog:
98102
>
99103
> ee. Fixed an off-by-one error when computing the number of positional parameters for the `${@:0:n}` expansion.
100104
105+
</details>
106+
101107
## bash v4.2
102108

103109
> [!CAUTION]
@@ -113,12 +119,15 @@ From changelog:
113119

114120
- Introduces `test -v VAR` for testing variable declaration
115121

116-
Changelog:
122+
<details>
123+
<summary>Changelog:</summary>
117124

118125
> This document details the changes between this version, `bash-4.2-alpha`, and the previous version, `bash-4.1-release`.
119126
>
120127
> f. `test`/`[`/`[[` have a new `-v` variable unary operator, which returns success if `variable` has been set.
121128
129+
</details>
130+
122131
## bash v4.3
123132

124133
> [!CAUTION]
@@ -137,14 +146,17 @@ From changelog:
137146
- Introduces `declare -n` for creating nameref variables.
138147
- Fixes a bug where `<&-` would not close the file descriptor
139148

140-
Changelog:
149+
<details>
150+
<summary>Changelog:</summary>
141151

142152
> This document details the changes between this version, `bash-4.3-alpha`, and the previous version, `bash-4.2-release`.
143153
>
144154
> w. The shell has `nameref` variables and new `-n`(/`+n`) options to declare and unset to use them, and a `test -R` option to test for them.
145155
>
146156
> bbbbb. Fixed a bug that caused redirections like <&n- to leave file descriptor n closed if executed with a builtin command.
147157
158+
</details>
159+
148160
## bash v4.4
149161

150162
> [!IMPORTANT]
@@ -161,7 +173,8 @@ From changelog:
161173

162174
- No longer throws upon accessing an empty array. Previously must do `[[ "${#arr[@]}" -ne 0 ]] && for item in "${arr[@]}"; do`.
163175

164-
Changelog:
176+
<details>
177+
<summary>Changelog:</summary>
165178

166179
> This document details the changes between this version, `bash-4.4-rc2`, and the previous version, `bash-4.4-beta2`.
167180
>
@@ -171,6 +184,8 @@ Changelog:
171184
>
172185
> d. The `mapfile` builtin now has a `-d` option to use an arbitrary character as the record delimiter, and a `-t` option to strip the delimiter as supplied with `-d`.
173186
187+
</details>
188+
174189
## bash v5.0
175190

176191
> [!NOTE]
@@ -180,7 +195,8 @@ From changelog:
180195

181196
- No longer causes strange duplications when working with `$'\001'`
182197

183-
Changelog:
198+
<details>
199+
<summary>Changelog:</summary>
184200

185201
> This document details the changes between this version, `bash-5.0-beta`, and the previous version, `bash-5.0-alpha`.
186202
>
@@ -218,18 +234,29 @@ Changelog:
218234
>
219235
> yyy. `wait` without arguments attempts to wait for all active process substitution processes.
220236
237+
</details>
238+
221239
## bash v5.1
222240

241+
> [!IMPORTANT]
242+
> This is this is the recommended minimum version for Dorothy on SUSE platforms.
243+
223244
> [!NOTE]
224245
> Dorothy's `bash.bash` provides cross-version compatible implementations of `__is_var_defined`, `__get_uppercase_first_letter`, `__get_lowercase_string`.
225246
226247
From changelog:
227248

249+
- Associative arrays now properly functional.
228250
- Introduces `${var@U}`, `${var@u}`, `${var@L}`
229251
- Introduces `test -v INDEX` for testing positional declaration
230-
- Associative arrays now properly functional.
252+
- Fixes `wait_for: No record of process ...` crashes; according to [this user report](https://gist.github.com/azat/affbda3f8c6b5c38648d4ab105777d88), it is this version that fixes it
231253

232-
Changelog:
254+
<details>
255+
<summary>Changelog:</summary>
256+
257+
> This document details the changes between this version, `bash-5.1-beta`, and the previous version, `bash-5.1-alpha`.
258+
>
259+
> e. Make sure `SIGCHLD` is blocked in all cases where `waitchld()` is not called from a signal handler.
233260
234261
> This document details the changes between this version, `bash-5.1-alpha`, and the previous version, `bash-5.0-release`.
235262
>
@@ -239,16 +266,95 @@ Changelog:
239266
>
240267
> oo. Fixed several issues with assigning an associative array variable using a compound assignment that expands the value of the same variable.
241268
269+
</details>
270+
242271
## bash v5.2
243272

244273
From changelog:
245274

246275
- Nameref variables (`declare -n nameref`) now properly functional.
247276

248-
Changelog:
277+
<details>
278+
<summary>Changelog:</summary>
249279

250280
> This document details the changes between this version, `bash-5.2-alpha`, and the previous version, `bash-5.1-release`.
251281
>
252282
> g. Fixed a problem with performing an assignment with `+=` to an array element that was the value of a nameref.
253283
> h. Fixed a bug that could cause a nameref containing an array reference using `@` or `*` not to expand to multiple words.
254284
> bb. Array references using `@` and `*` that are the value of nameref variables (`declare -n ref='v[@]' ; echo $ref`) no longer cause the shell to exit if `set -u` is enabled and the array (`v`) is unset.
285+
286+
</details>
287+
288+
## bash v5.3
289+
290+
From changelog:
291+
292+
- Introduces performant command interpolation, via command substitution `${command;}` or `${|command;}` instead of process substitution `$(command)`.
293+
- Introduces `fltexpr` for floating point arithmetic.
294+
- When debugging, `LINENO` is now correct.
295+
- We've likely encountered the plethora of bugs fixed in this version, however, by the time of its release, Dorothy already implemented workarounds, such that these bugs are not surfaced.
296+
297+
<details>
298+
<summary>Changelog:</summary>
299+
300+
> This document details the changes between this version, `bash-5.3-rc2`, and the previous version, `bash-5.3-rc1`.
301+
>
302+
> f. Fixed an issue with a backslash-newline appearing after a right paren in a nested subshell command.
303+
>
304+
> h. Fixed an issue with a nameref variable referencing an unset array element when the `nounset` option is enabled.
305+
306+
> This document details the changes between this version, `bash-5.3-rc1`, and the previous version, `bash-5.3-beta`.
307+
>
308+
> d. Changes to `set -e` exit behavior in posix mode, since POSIX now says to exit as if executing the `exit builtin with no arguments`.
309+
>
310+
> a. There is a new `fltexpr' loadable builtin to perform floating-point arithmetic similarly to `let'.
311+
312+
> This document details the changes between this version, `bash-5.3-beta`, and the previous version, `bash-5.3-alpha`.
313+
>
314+
> e. The bash build process now assumes a `C90` compilation environment and a `POSIX.1-1990` execution environment.
315+
>
316+
> x. Fix for return status for commands whose return status is being inverted when set -e is ignored.
317+
>
318+
> i. `wait -n` can now return terminated process substitutions, jobs about which the user has already been notified (like `wait` without options)
319+
>
320+
> q. If `exit` is run in a trap and not supplied an exit status argument, it uses the value of `$?` from before the trap only if it's run at the trap's `top level` and would cause the trap to end (that is, not in a subshell). This is from Posix interp 1602.
321+
322+
> This document details the changes between this version, `bash-5.3-alpha`, and the previous version, `bash-5.2-release`.
323+
>
324+
> c. Fixed a bug with subshell command execution that caused it to set `LINENO` incorrectly.
325+
>
326+
> g. Fixed a bug where nested word expansions confused the state parser and resulted in quotes being required where they should not have been.
327+
>
328+
> s. Fixed a bug that caused the shell to unlink FIFOs used for process substitution before a compound command completes.
329+
>
330+
> u. Fixed a bug that caused subshells not to run the `EXIT` trap if a signal arrived after the command and before returning to the caller.
331+
>
332+
> v. Fixed a bug where `wait` without arguments could wait for inherited process substitutions, which are not children of this shell.
333+
>
334+
> w. Fixed a bug with expanding $\* in a here-document body.
335+
>
336+
> y. Change for POSIX interpretation 1602 about the default return status for `return` in a trap command.
337+
>
338+
> gg. Fixed a bug that caused `eval` to run the ERR trap in commands where it should not.
339+
>
340+
> rrr. Treat the failure to open file in `$(<file)` as a non-fatal expansion error instead of a fatal redirection error.
341+
>
342+
> ttt. Fix `{var}>&-` so it doesn't silently close stdin if var is not a number.
343+
>
344+
> yyy. Fix bug that caused `FUNCNAME` not to be reset after a parse error with compound assignments to local variables.
345+
>
346+
> kkkk. `BASH_REMATCH` can now be a local variable.
347+
>
348+
> xxxx. Fix bug with closing `/dev/fd` process substitutions in shell functions.
349+
>
350+
> j. `trap` has a new `-P` option that prints the trap action associated with each signal argument.
351+
>
352+
> l. `printf` uses the `alternate form` for `%q` and `%Q` to force single quoting.
353+
>
354+
> s. New form of command substitution: `${ command; }` or `${|command;}` to capture the output of COMMAND without forking a child process and using pipes.
355+
>
356+
> q. `GLOBSORT`: new variable to specify how to sort the results of pathname expansion (`name`, `size`, `blocks`, `mtime`, `atime`, `ctime`, `none`) in ascending or descending order.
357+
>
358+
> x. `BASH_TRAPSIG`: new variable, set to the numeric signal number of the trap being executed while it's running.
359+
360+
</details>

sources/bash.bash

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,15 +490,22 @@ if [[ -z ${BASH_VERSION_CURRENT-} ]]; then
490490
BASH_VERSION_CURRENT="${BASH_VERSION_MAJOR}.${BASH_VERSION_MINOR}.${BASH_VERSION_PATCH}" # 5.2.15(1)-release => 5.2.15
491491
# trunk-ignore(shellcheck/SC2034)
492492
BASH_VERSION_LATEST='5.3' # https://ftp.gnu.org/gnu/bash/?C=M;O=D
493-
# any v5 version is supported by dorothy, earlier throws on empty array access which is annoying
494-
if [[ $BASH_VERSION_MAJOR -gt 4 || ($BASH_VERSION_MAJOR -eq 4 && $BASH_VERSION_MINOR -ge 4) ]]; then
493+
# bash v4.4 and above are supported by Dorothy, unless on SUSE in which it is v5.1 and above, see <versions.md> for reasoning
494+
# opensuse/leap hits a bash 4.4 error on the `is-same` test:
495+
# https://github.com/bevry/dorothy/actions/runs/17821527495/job/50664874215#step:4:24635
496+
# /github/home/.local/share/dorothy/commands/checksum: line 532: wait_for: No record of process 3552994
497+
# https://gist.github.com/azat/affbda3f8c6b5c38648d4ab105777d88
498+
if [[ ${MACTYPE-} =~ suse-linux-gnu$ && ($BASH_VERSION_MAJOR -lt 5 || ($BASH_VERSION_MAJOR -eq 5 && $BASH_VERSION_MINOR -lt 1)) ]]; then
499+
IS_BASH_VERSION_OUTDATED='yes'
500+
elif [[ $BASH_VERSION_MAJOR -gt 4 || ($BASH_VERSION_MAJOR -eq 4 && $BASH_VERSION_MINOR -ge 4) ]]; then
495501
IS_BASH_VERSION_OUTDATED='no'
496-
function __require_upgraded_bash {
497-
:
498-
}
499502
else
500-
# trunk-ignore(shellcheck/SC2034)
501503
IS_BASH_VERSION_OUTDATED='yes'
504+
fi
505+
if [[ $IS_BASH_VERSION_OUTDATED == 'no' ]]; then
506+
function __require_upgraded_bash { :; }
507+
else
508+
# trunk-ignore(shellcheck/SC2034)
502509
function __require_upgraded_bash {
503510
local reason="${1-}" reason_args=()
504511
if [[ -n $reason ]]; then
@@ -530,6 +537,7 @@ BASH_VERSIONS_SUPPORTED=(
530537
5.3 # compiles on macos x86 without any flags
531538
)
532539

540+
# convert a version (short and full) into its corresponding latest downloadable version identifier
533541
function __get_coerced_bash_version {
534542
local input="$1" result
535543
case "$input" in

0 commit comments

Comments
 (0)