I was preparing a site to be demoed and realized xhprof module was still enabled, so I tried to disable it.

I meant to type "drush dis -y xhprof".

In my haste, I typed drush *is*, -y, which ended up dropping my database.

Given how often we type -y, and how common dis is, it seems reasonable for the command to not be 1 letter away from dropping your database.

commonsint@ded-116:/var/www/html/commonsint.prod/docroot$ drush is xhprof 0-y
Warning: The command name "is" is deprecated.  Please use a recommended form instead (site-install,si).                            [warning]
You are about to DROP your 'commonsint' database and then CREATE a new one. Do you want to continue? (y/n): ^C

Comments

ezra-g’s picture

Another way of protecting folks from themselves would be to require a different type of confirmation for commands that drop your DB.

owen barton’s picture

I can see some folks insisting that we just need to type every command with care, but I agree with this - it's really easy to do right now.

How about something like this:

Regular commands:

  • -y means yes, just do it, no interaction needed (no change)

Commands that destroy data (sql-drop, site-install with existing db, pm-uninstall...others?):

  • User is prompted "This will destroy data. This operation is irreversible. Enter "yes", to continue."
  • User types "yes" to continue, Ctrl-C or anything else or abort (personally, I would lean away from allowing a short "y", but I can see some arguments to allow it).
  • -y alone has no effect
  • Using both "-y" and "--force" has the same effect as -y does now (I think one question is - would --force conflict with commands that might want that for other purposes?)
  • If someone prefers the current behavior, they could still set --force to TRUE for the commands they want to be able to pass "-y" to.
moshe weitzman’s picture

For the record, you must have typed si, not is. Thats more than one character off.

I'm not yet sold on the proposal but let's gather more feedback.

greg.1.anderson’s picture

I type destructive commands with -y fairly frequently, and mean it. Maybe we should just have a sample policy file that shows users how to add extra protection to destructive commands if they want it?

You can also override aliases that you don't like with a shell alias, which will take precedence over the built-in command.

$options['shell-aliases']['si'] = '!echo Can\'t touch this';

jonhattan’s picture

Version: 7.x-1.x-dev »

For the record, ezra-g seems to be using drush 4. Since 5.x, is is no an alias, but a shell-alias example in example.drushrc.php.

Other potentially destructive command is trying to simulate rsync run, since -s is a valid rsync flag.

-s as simulate: drush -s rsync %source %dest
-s to rsync: drush rsync -s %source %dest

greg.1.anderson’s picture

I would not mind getting rid of 'si' as an alias, but wouldn't want to see extra prompting implemented (outside of an example policy file).

greg.1.anderson’s picture

Version: » 8.x-6.x-dev
Status: Active » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.