How to drush enable a module only if is not installed I would like to drush enable a bunch of modules in a certain environment via a shell script that runs EVERY TIME the environment rebuilds when new code is committed. (This saves me from having to have access to a drush terminal when I want to first install a module in an environment, but means I don't know if module is being enabled for the first time or if it was enabled long ago)

I'm concerned there might be consequences of repeatedly enabling already enabled modules. Is this true?

If yes, I'm trying to find a drush command to enable a module only if it's not already enabled.

For example, I have seen this page:

drush en `drush pm-list --status="disabled,not installed" --pipe`


which enables all disabled modules.

and

drush dis `cat tmp.txt` --yes


which disables all modules listed in tmp.txt

I want something like:

drush en `magicfunction(tmp.txt, `drush pm-list --status="disabled" --pipe`)`


where magicfunction is some linux command line magic that returns the names of modules listed in tmp.txt that are also in the list of not enabled modules.

Any ideas?
You can use grep command to filter out the modules from disabled list to only which are appearing to your list, e.g.

drush -y en $(drush pm-list --status="disabled" --pipe | grep -f tmp.txt)




Other way is to use SQL query:

drush -y en $(drush sqlq "SELECT name FROM system WHERE name IN ('$(cat tmp.txt | paste -sd, | sed "s/,/','/")');")


which may be more complex, but quicker (especially when you replace drush sqlq with mysql -e command.