Skip to content
Browse files

Try to figure out which editor is available on *nix

  • Loading branch information...
1 parent 5768265 commit 7cb18c1a0cf3ee2309decba0079ff5dc2370ec06 @Seldaek Seldaek committed with
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/Composer/Command/ConfigCommand.php
View
11 src/Composer/Command/ConfigCommand.php
@@ -120,7 +120,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($input->getOption('editor')) {
$editor = getenv('EDITOR');
if (!$editor) {
- $editor = defined('PHP_WINDOWS_VERSION_BUILD') ? 'notepad' : 'vi';
+ if (defined('PHP_WINDOWS_VERSION_BUILD')) {
+ $editor = 'notepad';
+ } else {
+ foreach (array('vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
+ if (exec('which '.$candidate)) {
+ $editor = $candidate;
+ break;
+ }
+ }
+ }
}
system($editor . ' ' . $this->configFile->getPath() . (defined('PHP_WINDOWS_VERSION_BUILD') ? '': ' > `tty`'));

0 comments on commit 7cb18c1

Please sign in to comment.
Something went wrong with that request. Please try again.