Unverified Commit 9bf5bbb1 authored by Matthew Brett's avatar Matthew Brett Committed by GitHub
Browse files

Merge pull request #168 from matthew-brett/fix-is-function

MRG: fix and test is_function

See: #166

Thanks to Andrew Murray for pointing out this bug.
parents 54b7efc4 d27611e5
...@@ -88,7 +88,7 @@ function strip_ver_suffix { ...@@ -88,7 +88,7 @@ function strip_ver_suffix {
function is_function { function is_function {
# Echo "true" if input argument string is a function # Echo "true" if input argument string is a function
# Allow errors during "set -e" blocks. # Allow errors during "set -e" blocks.
(set +e; echo $($(declare -Ff "$1") > /dev/null && echo true)) (set +e; $(declare -Ff "$1" > /dev/null) && echo true)
} }
function gh-clone { function gh-clone {
......
...@@ -27,6 +27,16 @@ ...@@ -27,6 +27,16 @@
bar=baz bar=baz
[ "$(is_function bar)" == "" ] || ingest "is_function bar" [ "$(is_function bar)" == "" ] || ingest "is_function bar"
# Check function is not run in is_function. Thanks to Andrew Murray.
function rmfile {
rm testfile
}
touch testfile
[ "$(is_function rmfile)" == "true" ] || ingest "is_function rmfile"
[ -f testfile ] || ingest "testfile removed during isfunction check"
rm testfile
rm_mkdir tmp_dir rm_mkdir tmp_dir
[ -d tmp_dir ] || ingest "tmp_dir does not exist" [ -d tmp_dir ] || ingest "tmp_dir does not exist"
touch tmp_dir/afile touch tmp_dir/afile
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment