Skip to content

Add an option to install only if not already installed #2491

@redianthus

Description

@redianthus

Hi,

We recently added set -e in our CI script. We had something like:

#!/usr/bin/env bash

set -e

PACKAGES="cmake pkg-config fftw libogg libvorbis libsndfile libsamplerate jack sdl stk portaudio node fltk"

brew install $PACKAGES

With set -e, it failed because brew returned a non-zero exit code for already installed packages. So we had to do:

#!/usr/bin/env bash

set -e

PACKAGES="cmake pkg-config fftw libogg libvorbis libsndfile libsamplerate jack sdl stk portaudio node fltk"

# removing already installed packages from the list
for p in $(brew list); do
	PACKAGES=${PACKAGES//$p/}
done;

brew install $PACKAGES

But it's ugly and buggy. E.g. we used to have pkgconfig, so the string replacement didn't work. It now works cause we replaced it by pkg-config as it is in brew list output.

So, I'd like an option like: brew install --if-not-installed $PACKAGES which won't return a non-zero exit code if $PACKAGES contains already installed packages.

What do you think about it ? I wish i could implement it myself, but I don't know ruby and I'm not even a brew user so probably not the best option. I'm sure someone knowing ruby and brew could do this really quickly as it doesn't seem hard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions