From 4e3f4f24fc409bab90e40fba091b5281f22cc997 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 8 Oct 2012 19:22:48 +0200 Subject: [PATCH] Try to figure out which editor is available on *nix --- src/Composer/Command/ConfigCommand.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 044c80545..900b206e5 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -120,7 +120,16 @@ EOT 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`'));