Skip to content

Commit

Permalink
Add bash version requirements for certain functions
Browse files Browse the repository at this point in the history
  • Loading branch information
e8y committed Sep 9, 2024
1 parent 498a10e commit e57e14a
Show file tree
Hide file tree
Showing 7 changed files with 535 additions and 645 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MAJOR_VERSION=1
VERSION=1.20
VERSION=1.21

TARGET := bash-boost-$(VERSION)
SRCS := $(shell find src -type f -name "*.sh" | sort)
Expand Down
3 changes: 3 additions & 0 deletions docgen
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ sub formatmd {
elsif (my ($v) = ($text =~ m/^\s*\@returns:\s*(.*)$/)) {
print "\n**Returns:** $v\n";
}
elsif (($v) = ($text =~ m/^\s*\@requires:\s*(.*)$/)) {
print "\n**Requires:** bash $v or later\n";
}
elsif ($text =~ m/^\s*\@notes:/) {
print "\n**Notes:**\n\n";
}
Expand Down
8 changes: 7 additions & 1 deletion src/MANUAL.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: BASH-BOOST(1)
author: github.com/tomocafe
date: August 11, 2024
date: September 9, 2024
---


Expand Down Expand Up @@ -1133,6 +1133,8 @@ func() {

Unpacks list items into named variables

**Requires:** bash 4.3 or later

**Arguments:**

- `LISTVAR`: name of the list variable (do not include $)
Expand All @@ -1142,6 +1144,8 @@ Unpacks list items into named variables

Maps a function over a list, modifying it in place

**Requires:** bash 4.3 or later

**Arguments:**

- `LISTVAR`: name of the list variable (do not include $)
Expand All @@ -1151,6 +1155,8 @@ Maps a function over a list, modifying it in place

Maps a function over a list of keys to generate an associative array

**Requires:** bash 4.3 or later

**Arguments:**

- `LISTVAR`: name of an associative array variable (do not include $)
Expand Down
10 changes: 10 additions & 0 deletions src/core/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,13 @@ function bb_cleanup () {
done < <(set -o posix; set)
: # don't use return "$__bb_true" here, it's now undefined
}

function _bb_checkbashversion () {
[[ ${BASH_VERSINFO[0]} -lt ${1:-0} ]] && return $__bb_false
[[ ${BASH_VERSINFO[0]} -eq ${1:-0} && ${BASH_VERSINFO[1]} -lt ${2:-0} ]] && return $__bb_false
return $__bb_true
}

function _bb_unsupportedbashversion () {
echo "$1: requires bash ${2:-0}.${3:-0} or later (detected $BASH_VERSION)" 1>&2
}
Loading

0 comments on commit e57e14a

Please sign in to comment.