diff options
author | ng0 <ng0@n0.is> | 2019-12-16 11:50:31 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-12-16 11:50:31 +0000 |
commit | df3d04affac9ec8cddea62a140cf6f3216094d6f (patch) | |
tree | d83a756c0dea09c8f29e4beaccc99a5d98a5ec9a | |
parent | ba139160511026f08dd4611dc689ee5a211febf5 (diff) | |
download | build-common-df3d04affac9ec8cddea62a140cf6f3216094d6f.tar.gz build-common-df3d04affac9ec8cddea62a140cf6f3216094d6f.tar.bz2 build-common-df3d04affac9ec8cddea62a140cf6f3216094d6f.zip |
switch existence over to 'type', add shell check for type built-in support.
-rw-r--r-- | sh/lib.sh/existence.sh | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sh/lib.sh/existence.sh b/sh/lib.sh/existence.sh index a888dee..cddc3d6 100644 --- a/sh/lib.sh/existence.sh +++ b/sh/lib.sh/existence.sh @@ -18,10 +18,18 @@ # # SPDX-License-Identifier: 0BSD -# there is a function used in curl to replicate which(1), but -# it uses too many other tools. this one uses command and in -# gnunet so far has no reports about failures. +errmsg='' + +# Check if shell supports builtin 'type'. +if test -z "$errmsg"; then + if ! (eval 'type type') >/dev/null 2>&1 + then + errmsg='Shell does not support type builtin' + exit 1 + fi +fi + existence() { - command -v "$1" >/dev/null 2>&1 + type "$1" >/dev/null 2>&1 } |