drupal_rewrite_settings is an abomination on god-fearing configuration formats. That being said, it would be a little less heinous and reusable if it would at least return the contents of its evil-regex-doing instead of writing to conf_path() . '/settings.php';
Very minor change, but understood if it doesn't make it in.