Skip to content

Commit

Permalink
Fix #2817. bash autocomplete via .bashrc only works on the second .ba…
Browse files Browse the repository at this point in the history
…shrc inclusion.
  • Loading branch information
weitzman committed Jun 17, 2017
1 parent 95b57af commit 8c93e0c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions commands/core/init.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ function drush_init_core_init() {
drush_log(dt("Copied example Drush configuration file to !path", array('!path' => $drush_config_file)), LogLevel::OK);
}

// If Drush is not in the $PATH, then figure out which
// path to add so that Drush can be found globally.
$add_path = drush_get_option('add-path', NULL);
if ((!drush_which("drush") || $add_path) && ($add_path !== FALSE)) {
$drush_path = drush_find_path_to_drush($home);
$drush_path = preg_replace("%^" . preg_quote($home) . "/%", '$HOME/', $drush_path);

$bashrc_additions["%$drush_path%"] = "\n# Path to Drush, added by 'drush init'.\nexport PATH=\"\$PATH:$drush_path\"\n\n";
}

// If there is no ~/.drush/drush.bashrc file, then copy
// the example bashrc file there
if (!is_file($drush_bashrc)) {
Expand Down Expand Up @@ -91,16 +101,6 @@ function drush_init_core_init() {
// ~/.bashrc or ~/.bash_profile
$bashrc = drush_init_find_bashrc($home);

// If Drush is not in the $PATH, then figure out which
// path to add so that Drush can be found globally.
$add_path = drush_get_option('add-path', NULL);
if ((!drush_which("drush") || $add_path) && ($add_path !== FALSE)) {
$drush_path = drush_find_path_to_drush($home);
$drush_path = preg_replace("%^" . preg_quote($home) . "/%", '$HOME/', $drush_path);

$bashrc_additions["%$drush_path%"] = "\n# Path to Drush, added by 'drush init'.\nexport PATH=\"\$PATH:$drush_path\"\n\n";
}

// Modify the user's bashrc file, adding our customizations.
$bashrc_contents = "";
if (file_exists($bashrc)) {
Expand Down

0 comments on commit 8c93e0c

Please sign in to comment.