File tree 13 files changed +49
-24
lines changed
13 files changed +49
-24
lines changed Original file line number Diff line number Diff line change 6
6
[subrepo]
7
7
remote =
[email protected] :ingydotnet/bashplus.git
8
8
branch = master
9
- commit = e49f45a1457fed3cceb15bd4a82b0f7515efd8e5
10
- parent = 2e28e8a32166abdda154c4508c90176f356c1706
9
+ commit = 030d196bf621e971e223e95e73c235e6992b85e0
10
+ parent = 2c14be68fc5196ed1210d759421b33ef91c3e3db
11
11
cmdver = 0.4.1
12
12
method = merge
Original file line number Diff line number Diff line change 1
1
---
2
+ version: 0.1.0
3
+ date: Sat 14 Nov 2020 10:14:14 AM EST
4
+ changes:
5
+ - Add tests for version-check
6
+ - Improve version-check
7
+ - Move PATH assignment into test/setup
8
+ - Meta bashplus supports Bash 3.2
9
+ ---
2
10
version: 0.0.9
3
11
date: Wed 11 Nov 2020 02:19:32 PM EST
4
12
changes:
Original file line number Diff line number Diff line change 1
1
=meta: 0.0.2
2
2
3
3
name: bashplus
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
abstract: Modern Bash Programming
6
- homepage: http ://bpan.org/package /bashplus/
6
+ homepage: https ://github.com/ingydotnet /bashplus
7
7
8
8
license: MIT
9
9
copyright: 2013-2020
@@ -16,7 +16,7 @@ author:
16
16
homepage: http://ingy.net
17
17
18
18
requires:
19
- bash: 4.4.0
19
+ bash: 3.2
20
20
test:
21
21
cmd: make test
22
22
install:
Original file line number Diff line number Diff line change 6
6
7
7
[[ ${BASHPLUS_VERSION-} ]] && return 0
8
8
9
- BASHPLUS_VERSION=0.0.9
9
+ BASHPLUS_VERSION=0.1.0
10
10
11
11
bash+:version-check () {
12
12
local cmd want got out
13
13
14
14
IFS=' ' read -r -a cmd <<< " ${1:?}"
15
15
IFS=. read -r -a want <<< " ${2:?}"
16
+ : " ${want[0]:= 0} "
17
+ : " ${want[1]:= 0} "
16
18
: " ${want[2]:= 0} "
17
19
18
20
if [[ ${cmd[*]} == bash ]]; then
@@ -29,13 +31,11 @@ bash+:version-check() {
29
31
fi
30
32
: " ${got[2]:= 0} "
31
33
32
- ((
33
- got[0 ] > want[0 ] ||
34
- got[0 ] == want[0 ] && got[1 ] > want[1 ] ||
35
- got[0 ] == want[0 ] && got[1 ] == want[1 ] && got[2 ] >= want[2 ]
36
- )) || return 1
37
-
38
- return 0
34
+ (( got[0 ] > want[0 ] || ((
35
+ got[0 ] == want[0 ] && ((
36
+ got[1 ] > want[1 ] || ((
37
+ got[1 ] == want[1 ] && got[2 ] >= want[2 ]
38
+ )) )) )) ))
39
39
}
40
40
41
41
bash+:version-check bash 3.2 ||
Original file line number Diff line number Diff line change 2
2
3
3
source test/setup
4
4
5
- PATH=$PWD /bin:$PATH
6
5
source bash+ :std
7
6
8
7
ok $? " 'source bash+' works"
9
8
10
- is " $BASHPLUS_VERSION " ' 0.0.9 ' ' BASHPLUS_VERSION is 0.0.9 '
9
+ is " $BASHPLUS_VERSION " ' 0.1.0 ' ' BASHPLUS_VERSION is 0.1.0 '
11
10
12
11
done_testing 2
Original file line number Diff line number Diff line change 2
2
3
3
source test/setup
4
4
5
- PATH=$PWD /bin:$PATH
6
5
source bash+ :std
7
6
8
7
got=$( die " Nope" 2>&1 ) || true
9
8
want=" Nope
10
- at line 8 in main of test/die.t"
9
+ at line 7 in main of test/die.t"
11
10
is " $got " " $want " " die() msg ok"
12
11
13
12
got=$( die " Nope\n" 2>&1 ) || true
Original file line number Diff line number Diff line change 2
2
3
3
source test/setup
4
4
5
- PATH=$PWD /bin:$PATH
6
5
source bash+
7
6
8
7
foo () {
Original file line number Diff line number Diff line change 7
7
# how nice Bash can be.
8
8
# ------------------------------------------------------------------------------
9
9
10
- set -e -u -o pipefail
11
- [[ $BASH_VERSION == 4.0* ]] && set +u
10
+ set -e -o pipefail
11
+
12
+ PATH=$PWD /bin:$PATH
12
13
13
14
run=0
14
15
Original file line number Diff line number Diff line change 2
2
3
3
source test/setup
4
4
5
- PATH=$PWD /bin:$PATH
6
5
source bash+
7
6
8
7
if ! command -v shellcheck > /dev/null; then
Original file line number Diff line number Diff line change 2
2
3
3
source test/setup
4
4
5
- PATH=$PWD /bin:$PATH
6
5
source bash+ :std
7
6
8
7
ok " $( bash+:can use) " ' use is imported'
Original file line number Diff line number Diff line change 2
2
3
3
source test/setup
4
4
5
- PATH=$PWD /bin:$PATH
6
5
source bash+
7
6
8
7
functions=(
Original file line number Diff line number Diff line change 2
2
3
3
source test/setup
4
4
5
- PATH=$PWD /bin:$PATH
6
5
source bash+ :std can
7
6
8
7
# shellcheck disable=2034
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ source test/setup
4
+
5
+ PATH=$PWD /bin:$PATH
6
+ source bash+ version-check
7
+
8
+ t1 () (echo 0.1.2)
9
+ t2 () (echo 0.1)
10
+
11
+ ok " $( version-check t1 0) " " 0.1.2 >= 0"
12
+ ok " $( version-check t1 0.1) " " 0.1.2 >= 0.1"
13
+ ok " $( version-check t1 0.1.1) " " 0.1.2 >= 0.1.1"
14
+ ok " $( version-check t1 0.1.2) " " 0.1.2 >= 0.1.2"
15
+ ok " $( ! version-check t1 0.2) " " 0.1.2 >= 0.2 fails"
16
+ ok " $( ! version-check t1 0.1.3) " " 0.1.2 >= 0.1.3 fails"
17
+
18
+ ok " $( version-check t2 0) " " 0.1 >= 0"
19
+ ok " $( version-check t2 0.1) " " 0.1 >= 0.1"
20
+ ok " $( ! version-check t2 0.2) " " 0.1 >= 0.2 fails"
21
+ ok " $( ! version-check t2 0.1.1) " " 0.1 >= 0.1.1"
22
+
23
+ done_testing 10
You can’t perform that action at this time.
0 commit comments