Skip to content

Commit 66cb5b8

Browse files
committed
Fixing utils.functions-matching.diff(); v2.5.1
This is a very important function in this library.
1 parent 4d2ad7e commit 66cb5b8

File tree

7 files changed

+21
-5
lines changed

7 files changed

+21
-5
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.5.0
1+
2.5.1

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"compile-hero.disable-compile-files-on-did-save-code": true,
1010
"shellcheck.enableQuickFix": true,
1111
"workbench.colorTheme": "Popping and Locking",
12-
"window.zoomLevel": 0,
12+
"window.zoomLevel": 1,
1313
"customPresentationMode.backup": {},
1414
"gruvboxMaterial.jsson1Comments": false,
1515
"git-graph.markdown": false

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[separator=—]
22
= Bashmatic® — BASH-based DSL helpers for humans, sysadmins, and fun.
33
// vim: ft=asciidoc
4-
:author: Version v2.4.6
4+
:author: Version v2.5.0
55
:doctype: book
66
:source-highlighter: rouge
77
:rouge-style: base16.monokai

README.pdf

0 Bytes
Binary file not shown.

doc/USAGE.pdf

-96 Bytes
Binary file not shown.

lib/util.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ util.rot13() {
3434
}
3535

3636
alias rot13=util.rot13
37+
__grep="${GrepCommand/ */}"
38+
[[ -n ${__grep} && -x ${__grep} ]] || {
39+
export GrepCommand="$(command -v grep) -E"
40+
}
3741

3842
util.is-variable-defined() {
3943
local var_name="$1"
@@ -211,11 +215,11 @@ util.functions-starting-with-csv() {
211215
util.functions-matching() {
212216
local prefix="${1}"
213217
local extra_command=${2:-"cat"}
214-
set | ${GrepCommand} '^${prefix}' | sedx 's/[\(\)]//g;' | /usr/bin/tr -d ' ' | /usr/bin/tr '\n' ' '
218+
declare -f | ${GrepCommand} "^${prefix}" | sedx 's/[\(\)]//g;' | /usr/bin/tr -d ' ' | /usr/bin/tr '\n' ' '
215219
}
216220

217221
util.functions-matching.diff() {
218-
for m in "$@"; do
222+
while true; do
219223
[[ -z "$1" ]] && break
220224
for e in $(util.functions-matching "${1}"); do
221225
printf "${e/$1/}\n"

test/util_test.bats

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ load test_helper
55
source lib/util.sh
66
source lib/user.sh
77
source lib/is.sh
8+
source lib/db.sh
9+
source lib/db_cli.sh
10+
source lib/db_rails.sh
11+
source lib/db_top.sh
812

913
set -e
1014

@@ -67,3 +71,11 @@ moo() {
6771
set -e
6872
[ $code -ne 0 ]
6973
}
74+
75+
@test "util.functions-matching.diff" {
76+
set -e
77+
local -a actions=($(util.functions-matching.diff db.actions. | sort))
78+
local num=${#actions[@]}
79+
[[ $num -gt 10 ]] &&
80+
[[ "${actions[0]}" == "commands" ]]
81+
}

0 commit comments

Comments
 (0)