0

I'm writing a really basic bash script and want use drush dl to download the Drush extras add on.

drush dl drush_extras

But I need to check whether drush extras is installed before I try to install it (and then use it) because it prompts the following text.

Install location C:\cygwin64\home\USER/.drush/drush_extras already exists. Do you want to overwrite it? (y/n):

How do I determine whether a drush add on/plug in/module (not sure what you call it) exists? So I handle that use case?

I'm trying to automate configuration, starting with assigning blocks to regions, and I have to make it work on Windows (first) and Linux. So I'm using Cygwin and Drush on Windows. There's probably different approaches, but this seems OK.

1
  • Welcome to Drupal Answers! So far, you stated facts, but it's not clear what you need to know, or (in other words) what you don't understand in achieving the described task.
    – apaderno
    Jun 3, 2018 at 12:28

1 Answer 1

1

I would personally lean towards simply installing with -y. Adding -y onto the command you've listed will return Y accepting the default on any prompt that comes up (like the one you mention).

drush dl drush_extras -y

If you still want to check if it’s installed, you can check if the directory exists,

if [ -e $HOME/.drush/drush_extras ]; then
  # some logic here
fi 

This won’t help you if the directory is empty though.

Another option is checking the output of

drush someCommand -h

Where someCommand is a command provided by drush_extras. You can compare the output of a valid one to an invalid one. If they match, it’s not installed.

2
  • "Adding -y will return Y accepting the default on any prompt that comes up (like the one you mention)." I've looked here but can't see the -y option, is this specific to drush dl or a general feature of shell commands?
    – ja_him
    Jun 2, 2018 at 17:18
  • 1
    @ja_him It’s a drush built in feature. Try running drush or drush -h. I believe it comes up towards the beginning of the output. --yes is the expanded version of the command.
    – rovr138
    Jun 2, 2018 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.