function drush_save_config

8.0.x drush_save_config($context)
6.x drush_save_config($context)
7.x drush_save_config($context)
3.x drush_save_config($context)
4.x drush_save_config($context)
5.x drush_save_config($context)
master drush_save_config($context)

Save the settings in a specific context to the applicable configuration file This is useful is you want certain settings to be available automatically the next time a command is executed.


$context: The context to save


includes/, line 534
The Drush context API implementation.


function drush_save_config($context) {
  $filename = _drush_config_file($context);

  if ($filename) {
    $cache = drush_get_context($context);

    $fp = fopen($filename, "w+");
    if (!$fp) {
      return drush_set_error('DRUSH_PERM_ERROR', dt('Drushrc (!filename) could not be written', array('!filename' => $filename)));
    else {
      fwrite($fp, "<?php\n");
      $timestamp = mktime();
      foreach ($cache as $key => $value) {
        $line = "\n\$options['$key'] = " . var_export($value, TRUE) . ';';
        fwrite($fp, $line);
      fwrite($fp, "\n");
      drush_log(dt('Drushrc file (!filename) was written successfully', array('!filename' => $filename)));
      return true;

  return false;