@@ -26,7 +26,7 @@ bash+:export:std() { @ use die warn; }
26
26
bash+:use () {
27
27
local library_name=" ${1:? bash+: use requires library name} " ; shift
28
28
local library_path=" $( bash+:findlib $library_name ) "
29
- [ -n " $library_path " ] || {
29
+ [[ -n $library_path ] ] || {
30
30
bash+:die " Can't find library '$library_name '." 1
31
31
}
32
32
source " $library_path "
@@ -41,7 +41,7 @@ bash+:use() {
41
41
bash+:import () {
42
42
local arg=
43
43
for arg; do
44
- if [[ " $arg " =~ ^: ]]; then
44
+ if [[ $arg =~ ^: ]]; then
45
45
bash+:import ` bash+:export$arg `
46
46
else
47
47
bash+:fcopy bash+:$arg $arg
@@ -54,7 +54,7 @@ bash+:fcopy() {
54
54
bash+:can " ${1:? bash+: fcopy requires an input function name} " ||
55
55
bash+:die " '$1 ' is not a function" 2
56
56
local func=$( type " $1 " 3> /dev/null | tail -n+3)
57
- [ -n " $3 " ] && " $3 "
57
+ [[ -n $3 ] ] && " $3 "
58
58
eval " ${2:? bash+: fcopy requires an output function name} () $func "
59
59
}
60
60
@@ -72,10 +72,10 @@ bash+:die() {
72
72
local msg=" ${1:- Died} "
73
73
printf " ${msg// \\ n/ $' \n ' } " >&2
74
74
local trailing_newline_re=$' \n ' ' $'
75
- [[ " $msg " =~ $trailing_newline_re ]] && exit 1
75
+ [[ $msg =~ $trailing_newline_re ]] && exit 1
76
76
77
77
local c=($( caller ${DIE_STACK_LEVEL:- ${2:- 0} } ) )
78
- [ ${# c[@]} -eq 2 ] &&
78
+ (( ${# c[@]} == 2 )) &&
79
79
msg=" at line %d of %s" ||
80
80
msg=" at line %d in %s of %s"
81
81
printf " $msg \n" ${c[@]} >&2
@@ -88,5 +88,5 @@ bash+:warn() {
88
88
}
89
89
90
90
bash+:can () {
91
- [ " $( type -t " ${1:? bash+: can requires a function name} " ) " == function ]
91
+ [[ $( type -t " ${1:? bash+: can requires a function name} " ) == function ] ]
92
92
}
0 commit comments