Detect if homebrew package is installed

前端 未结 4 1040
梦如初夏
梦如初夏 2021-01-30 04:42

I\'m about to write a shell script to detect if several homebrew packages are installed in the system. Is there a way to use a brew command to achieve that?

I tried usin

4条回答
  •  时光说笑
    2021-01-30 05:39

    Easiest two-liners: Step one, make sure it's installed

    $ realpath . || brew install coreutils
    

    This will print out the realpath of current dir, if not, then it will install it. And it will not fail even realpath not found.

    Step two, call it in your actual code:

    $ realpath ${someDir}
    

提交回复
热议问题