@@ -15,49 +15,49 @@ case "$OSTYPE" in
1515 ' darwin' * ) BASH_IT_SED_I_PARAMETERS=(-i " " )
1616esac
1717
18- function _command_exists ()
19- {
20- _about ' checks for existence of a command'
21- _param ' 1: command to check'
22- _param ' 2: (optional) log message to include when command not found'
23- _example ' $ _command_exists ls && echo exists'
24- _group ' lib'
25- local msg=" ${2:- Command ' $1' does not exist! } "
26- if type -t " $1 " & > /dev/null
27- then
28- return 0
29- else
30- _log_warning " $msg "
31- return 1
32- fi
18+ function _command_exists() {
19+ _about ' checks for existence of a command'
20+ _param ' 1: command to check'
21+ _param ' 2: (optional) log message to include when command not found'
22+ _example ' $ _command_exists ls && echo exists'
23+ _group ' lib'
24+ local msg=" ${2:- Command ' $1' does not exist} "
25+ if type -t " $1 " > /dev/null; then
26+ return 0
27+ else
28+ _log_debug " $msg "
29+ return 1
30+ fi
3331}
3432
35- function _binary_exists ()
36- {
37- _about ' checks for existence of a binary'
38- _param ' 1: binary to check'
39- _param ' 2: (optional) log message to include when binary not found'
40- _example ' $ _binary_exists ls && echo exists'
41- _group ' lib'
42- local msg=" ${2:- Binary ' $1' does not exist! } "
43- if type -P " $1 " & > /dev/null
44- then
45- return 0
46- else
47- _log_warning " $msg "
48- return 1
49- fi
33+ function _binary_exists() {
34+ _about ' checks for existence of a binary'
35+ _param ' 1: binary to check'
36+ _param ' 2: (optional) log message to include when binary not found'
37+ _example ' $ _binary_exists ls && echo exists'
38+ _group ' lib'
39+ local msg=" ${2:- Binary ' $1' does not exist} "
40+ if type -P " $1 " > /dev/null; then
41+ return 0
42+ else
43+ _log_debug " $msg "
44+ return 1
45+ fi
5046}
5147
52- function _completion_exists ()
53- {
54- _about ' checks for existence of a completion'
55- _param ' 1: command to check'
56- _param ' 2: (optional) log message to include when completion is found'
57- _example ' $ _completion_exists gh && echo exists'
58- _group ' lib'
59- local msg=" ${2:- Completion for ' $1' already exists! } "
60- complete -p " $1 " & > /dev/null && _log_warning " $msg " ;
48+ function _completion_exists() {
49+ _about ' checks for existence of a completion'
50+ _param ' 1: command to check'
51+ _param ' 2: (optional) log message to include when completion is found'
52+ _example ' $ _completion_exists gh && echo exists'
53+ _group ' lib'
54+ local msg=" ${2:- Completion for ' $1' already exists} "
55+ if complete -p " $1 " & > /dev/null; then
56+ _log_debug " $msg "
57+ return 0
58+ else
59+ return 1
60+ fi
6161}
6262
6363function _bash_it_homebrew_check()
@@ -179,12 +179,20 @@ bash-it ()
179179 fi
180180}
181181
182- _is_function ()
183- {
184- _about ' sets $? to true if parameter is the name of a function'
185- _param ' 1: name of alleged function'
186- _group ' lib'
187- [ -n " $( LANG=C type -t $1 2> /dev/null | grep ' function' ) " ]
182+ function _is_function() {
183+ _about ' sets $? to true if parameter is the name of a function'
184+ _param ' 1: name of alleged function'
185+ _param ' 2: (optional) log message to include when function not found'
186+ _group ' lib'
187+ _example ' $ _is_function ls && echo exists'
188+ _group ' lib'
189+ local msg=" ${2:- Function ' $1' does not exist} "
190+ if LC_ALL=C type -t " $1 " | _bash-it-egrep -q ' function' ; then
191+ return 0
192+ else
193+ _log_debug " $msg "
194+ return 1
195+ fi
188196}
189197
190198_bash-it-aliases ()
0 commit comments