The following commit: 9385e182, added an & at the end of the drush conf command:
return drush_shell_exec_interactive('$EDITOR %s &', $all[$choice]);
which makes the call to $EDITOR a background process. But this doesn't work if your editor is vim and you run it in a terminal or if you are ssh'd into a server, and you try to use drush conf to open config files.
I get the following error when I ssh into a server and run drush conf:
emacs: standard input is not a tty
Is there a way to tell if the editor of choice needs to run in the terminal as a foreground process and not append the & in that case?
Thanks,
Bart
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | drush-add_foreground_option_conf-1495550-6.patch | 2.47 KB | bartlantz |
| #4 | drush-add_background_option_conf-1495550-4.patch | 2.43 KB | bartlantz |
Comments
Comment #1
greg.1.anderson commentedI was working on adjusting my bash configuration files to set EDITOR to a GUI editor when running from an X session, and set it to vi or vim when running via ssh. At the moment, I am looking at the DISPLAY environment variable to determine this; using this technique means that you get your GUI editor when ssh'ed in with an X-tunnel, which may or may not be what you want.
Maybe Drush should do something similar, and use EDITOR with '&' when in GUI mode, and use CONSOLE_EDITOR without '&' when in console mode.
Comment #2
greg.1.anderson commentedI am wondering if perhaps 9385e182 should be backed out for now. This is a very recent change; it is unknown at this point how many people it will impact negatively. The GUI editor I use returns control to the commandline immediately when it is called; while this is not universal behavior, it is common. So, not everyone is helped by the '&', and some are inconvenienced by it. Perhaps a short-term compromise would be to add a 'background' flag to drush conf, so that those who need it may request it.
Comment #3
moshe weitzman commentedThat commit is almost exactly a year old. Mind your years!
Anyway, I don't recall why I wanted it. Moving to an option for the '&' works for me. I have no opinion on the default for that option.
Comment #4
bartlantz commentedHere's a patch that adds an option "--background" to drush config. When it's set, it will open the editor as a background process, otherwise it opens the editor in the foreground.
Comment #5
greg.1.anderson commentedDrush-5 has shipped with background as the default behavior for
drush conf. If we add a flag at this point, the default will need to be in the background to avoid changing existing behavior.Comment #6
bartlantz commentedThat makes complete sense! I didn't think about that. Here's the patch updated so that it defaults to opening the editor in the background, and if the user passes in the --foreground option, it calls the $EDITOR without the ampersand.
Thanks,
Bart
Comment #7
bartlantz commentedForgot to switch status to needs review.
Comment #8
joestewart commentedpatch applied fine. The patch and the --foreground switch worked for me with vim and nano. And failed without.
I tried a bunch of other editors that all returned back to the shell prompt without issue.
Comment #9
greg.1.anderson commentedA variant of this was committed a while back; somehow we reversed on #5 and made foreground the default. That is probably the best behavior, and just a small hit on backwards compatibility.