How can I check if a program exists from a Bash script?

后端 未结 30 1984
有刺的猬
有刺的猬 2020-11-21 07:21

How would I validate that a program exists, in a way that will either return an error and exit, or continue with the script?

It seems like it should be easy, but it\

30条回答
  •  死守一世寂寞
    2020-11-21 07:43

    I wanted the same question answered but to run within a Makefile.

    install:
        @if [[ ! -x "$(shell command -v ghead)" ]]; then \
            echo 'ghead does not exist. Please install it.'; \
            exit -1; \
        fi
    

提交回复
热议问题