Drush Strict Option Handling

Drush allows for commands to have options. I typically run commands such as:

drush dl views views_ui -y; drush en views views_ui --yes;

This will download and install the Views module.

Some Drush commands enforce (but all support) something called Strict Option Handling.

This allows the Drush options for a command to be unambiguously used by Drush and pass on additional options to sub commands in your shell script.

You may find for example this command — doesn’t do what you want (bypass confirmation with -y):

drush rsync @development:sites/all/themes @production:sites/all/themes -y

By default the Drush rysnc command and Drush ssh command use strict option handling — due to how the sub commands make use of additional arguments in Bash (such as –exclude for Rsync).

A nice reference for Drush commands I recently stumbled upon is DrushCommands. I find its layout and usage efficient to use.

The structure for Drush commands using strict option handling would be:

drush [global options] command [command options]

This will pass [global options] to Drush and [command options] to shell commands.

It’s a good habit to place -y and other global options right after you type Drush. So oddball commands like Rsync and SSH don’t trip you up when using Drush and you try to pass options to them.

Rewriting the above commands we would get:

drush -y dl views; drush -y en views views_ui;

Looking for quality Drupal Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , | Posted under Drupal, Drush | RSS 2.0

Author Spotlight

David Gurba

I am a web programmer currently employed at UCSB. I have been developing web applications professionally for 8+ years now. For the last 5 years I’ve been actively developing websites primarily in PHP using Drupal. I have experience using LAMP and developing data driven websites for clients in aviation, higher education and e-commerce. If you’d like to contact me I can be reached at david.gurba@arvixe.com

Leave a Reply

Your email address will not be published. Required fields are marked *