diff --git a/commands/core/variable.drush.inc b/commands/core/variable.drush.inc
index c199ba2..9b9cf63 100644
--- a/commands/core/variable.drush.inc
+++ b/commands/core/variable.drush.inc
@@ -39,13 +39,12 @@ function variable_drush_command() {
     'options' => array(
       'yes' => 'Skip confirmation if only one variable name matches.',
       'always-set' => 'Always skip confirmation.',
-      'format' => 'Format to parse the object. Use "string" for string (default), and "json" for JSON.',
+      'format' => 'Format to parse the object. Use "auto" to detect format from value (default), "string", "integer" or "boolean" for corresponding primitive type, and "json" for JSON.',
     ),
     'examples' => array(
-      'drush vset --yes preprocess_css 1' => 'Set the preprocess_css variable to true. Skip confirmation if variable already exists.',
-      'drush vset --always-set site_offline 1' => 'Take the site offline; Skips confirmation even if site_offline variable does not exist.',
-      'drush vset pr 1' => 'Choose from a list of variables beginning with "pr" to set to true.',
-      'php -r "print json_encode(TRUE);" | drush vset --format=json foo -' => 'Set foo to a boolean value',
+      'drush vset --yes preprocess_css TRUE' => 'Set the preprocess_css variable to true. Skip confirmation if variable already exists.',
+      'drush vset --always-set maintenance_mode 1' => 'Take the site offline; skips confirmation even if maintenance_mode variable does not exist. Variable is rewritten to site_offline for Drupal 6 and earlier.',
+      'drush vset pr TRUE' => 'Choose from a list of variables beginning with "pr" to set to (bool)true.',
       'php -r "print json_encode(array(\'drupal\', \'simpletest\'));"  | drush vset --format=json project_dependency_excluded_dependencies -'=> 'Set a variable to a complex value (e.g. array)',
     ),
     'aliases' => array('vset'),
@@ -58,10 +57,12 @@ function variable_drush_command() {
     'required-arguments' => TRUE,
     'options' => array(
       'yes' => 'Skip confirmation if only one variable name matches.',
+      'exact' => 'Only delete the one variable that exactly matches the specified name.',
     ),
     'examples' => array(
       'drush vdel user_pictures' => 'Delete the user_pictures variable.',
       'drush vdel u' => 'Choose from a list of variables beginning with "u" to delete.',
+      'drush vdel -y --exact maintenance_mode' => 'Bring the site back online, skipping confirmation. Variable is rewritten to site_offline for Drupal 6 and earlier.',
     ),
     'aliases' => array('vdel'),
   );
@@ -113,6 +114,7 @@ function drush_variable_get() {
 
   $keys = array_keys($conf);
   if ($args = func_get_args()) {
+    $args[0] = drush_variable_name_adjust($args[0]);
     $keys = preg_grep("/{$args[0]}/", $keys);
   }
 
@@ -142,6 +144,7 @@ function drush_variable_set() {
     return drush_set_error('DRUSH_VARIABLE_ERROR', dt('No value specified.'));
   }
 
+  $args[0] = drush_variable_name_adjust($args[0]);
   $result = drush_variable_like($args[0]);
 
   $options[] = "$args[0] ". dt('(new variable)');
@@ -160,21 +163,29 @@ function drush_variable_set() {
     $value = stream_get_contents(STDIN);
   }
 
-  // Now, we parse the object.
-  switch (drush_get_option('format', 'string')) {
-    case 'json':
-      $value = drush_json_decode($value);
-      break;
+  // If the value is a string (usual case, unless we are called from code),
+  // then format the input
+  if (is_string($value)) {
+    $value = _drush_variable_format($value, drush_get_option('format', 'auto'));
   }
 
+  // Format the output for display
+  if (is_array($value)) {
+    $display = "\n" . var_export($value, TRUE);
+  }
+  elseif (is_integer($value)) {
+    $display = $value;
+  }
+  elseif (is_bool($value)) {
+    $display = $value ? "TRUE" : "FALSE";
+  }
+  else {
+    $display = '"' . $value . '"';
+  }
+  
   if (drush_get_option('always-set', FALSE) || count($options) == 1 || $match) {
     variable_set($args[0], $value);
-    if (is_scalar($value)) {
-      drush_log(dt('!name was set to !value.', array('!name' => $args[0], '!value' => $value)), 'success');
-    }
-    else {
-      drush_log(dt('!name was set.', array('!name' => $args[0])), 'success');
-    }
+    drush_log(dt('!name was set to !value.', array('!name' => $args[0], '!value' => $display)), 'success');
     return '';
   }
   else {
@@ -183,17 +194,54 @@ function drush_variable_set() {
       $choice = $options[$choice];
       $choice = str_replace(' ' . dt('(new variable)'), '', $choice);
       drush_op('variable_set', $choice, $value);
-      drush_log(dt('!name was set to !value', array('!name' => $choice, '!value' => $value)), 'success');
+      drush_log(dt('!name was set to !value', array('!name' => $choice, '!value' => $display)), 'success');
     }
   }
 }
 
+function _drush_variable_format($value, $format) {
+  if ($format == 'auto') {
+    if (is_numeric($value)) {
+      $format = 'integer';
+    }
+    elseif (($value == 'TRUE') || ($value == 'FALSE')) {
+      $format = 'bool';
+    }
+  }
+
+  // Now, we parse the object.
+  switch ($format) {
+    case 'integer':
+      $value = (integer)$value;
+      break;
+    
+    case 'bool':
+    case 'boolean':
+      if ($value == 'TRUE') {
+        $value = TRUE;
+      }
+      elseif ($value == 'FALSE') {
+        $value = FALSE;
+      }
+      else {
+        $value = (bool)$value;
+      }
+      break;
+
+    case 'json':
+      $value = drush_json_decode($value);
+      break;
+  }
+  return $value;
+}
+
 /**
  * Command callback.
  * Delete a variable.
  */
 function drush_variable_delete() {
   $args = func_get_args();
+  $args[0] = drush_variable_name_adjust($args[0]);
   // Look for similar variable names.
   $result = drush_variable_like($args[0]);
 
@@ -201,6 +249,9 @@ function drush_variable_delete() {
   while ($name = drush_db_result($result)) {
     $options[] = $name;
   }
+  if (drush_get_option('exact', FALSE)) {
+    $options = in_array($args[0], $options) ? array($args[0]) : array();
+  }
 
   if (count($options) == 0) {
     drush_print(dt('!name not found.', array('!name' => $args[0])));
@@ -226,3 +277,14 @@ function drush_variable_delete() {
 function drush_variable_like($arg) {
   return drush_db_select('variable', 'name', 'name LIKE :keyword', array(':keyword' => $arg . '%'), NULL, NULL, 'name');
 }
+
+// Unify similar variable names across different versions of Drupal
+function drush_variable_name_adjust($arg) {
+  if (($arg == 'maintenance_mode') && (drush_drupal_major_version() < 7)) {
+    $arg = 'site_offline';
+  }
+  if (($arg == 'site_offline') && (drush_drupal_major_version() >= 7)) {
+    $arg = 'maintenance_mode';
+  }
+  return $arg;
+}
diff --git a/examples/example.drushrc.php b/examples/example.drushrc.php
index d89dc91..0dc29f8 100644
--- a/examples/example.drushrc.php
+++ b/examples/example.drushrc.php
@@ -72,6 +72,8 @@
 # $options['shell-aliases']['noncore'] = 'pm-list --no-core';
 # $options['shell-aliases']['wipe'] = 'cache-clear all';
 # $options['shell-aliases']['unsuck'] = 'pm-disable -y overlay,dashboard';
+# $options['shell-aliases']['offline'] = 'variable-set -y --always-set maintenance_mode 1';
+# $options['shell-aliases']['online'] = 'variable-delete -y --exact maintenance_mode';
 // Add a 'pm-clone' to simplify (cached) git cloning from drupal.org.
 # $options['shell-aliases']['pm-clone'] = 'pm-download --gitusername=YOURUSERNAME --package-handler=git_drupalorg --cache';
 
diff --git a/includes/drush.inc b/includes/drush.inc
index de58c09..9d3d71e 100644
--- a/includes/drush.inc
+++ b/includes/drush.inc
@@ -386,6 +386,7 @@ function drush_get_global_options($brief = FALSE) {
     $options['reserve-margin']      = array('hidden' => TRUE, 'description' => 'Remove columns from formatted opions. Managed by multi-site command handling.');
     $options['strict']              = array('hidden' => TRUE, 'description' => 'Check requirements more strictly / remove backwards-compatibility features for unit tests.');
     $options['command-specific']    = array('hidden' => TRUE, 'merge-associative' => TRUE, 'description' => 'Command-specific options.');
+    $options['state-def']           = array('hidden' => TRUE, 'merge-associative' => TRUE, 'description' => 'State definitions for core-state command.');
     $options['site-aliases']        = array('hidden' => TRUE, 'merge-associative' => TRUE, 'description' => 'List of site aliases.');
     $options['shell-aliases']       = array('hidden' => TRUE, 'merge' => TRUE, 'never-propagate' => TRUE, 'description' => 'List of shell aliases.');
 
