diff mbox series

[testsuite,1/2] check-syntax: use 'command -v' instead of 'which'

Message ID 20210122102748.38776-2-omosnace@redhat.com (mailing list archive)
State Accepted
Delegated to: Ondrej Mosnáček
Headers show
Series Migrate CI to GH Actions | expand

Commit Message

Ondrej Mosnacek Jan. 22, 2021, 10:27 a.m. UTC
In minimal environments (e.g. Fedora container image) 'which' is not
installed by default. To avoid the need to install an additional
dependency, use 'command -v', which also does the trick and is a shell
builtin.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 tools/check-syntax | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul Moore Jan. 22, 2021, 3:47 p.m. UTC | #1
On Fri, Jan 22, 2021 at 5:46 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> In minimal environments (e.g. Fedora container image) 'which' is not
> installed by default. To avoid the need to install an additional
> dependency, use 'command -v', which also does the trick and is a shell
> builtin.
>
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---
>  tools/check-syntax | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Nice.

Acked-by: Paul Moore <paul@paul-moore.com>
diff mbox series

Patch

diff --git a/tools/check-syntax b/tools/check-syntax
index 0ca79e2..2115a79 100755
--- a/tools/check-syntax
+++ b/tools/check-syntax
@@ -27,7 +27,7 @@  CHK_PERL_EXCLUDE=""
 #
 function verify_deps() {
 	[[ -z "$1" ]] && return
-	if ! which "$1" >& /dev/null; then
+	if ! command -v "$1" >& /dev/null; then
 		echo "error: install \"$1\" and include it in your \$PATH"
 		exit 1
 	fi