Bug #7205
closed`arv edit` cannot be used when stdout is not connected to a TTY
Description
If one tries to use `arv edit` non-interactively (i.e. by redirecting the output to a file) it detects that, exits with an error, and fails to produce useful output:
$ EDITOR=cat arv edit 7lnae-p5p6p-ffosu62mxxoky3p > /tmp/pipeline.json $ echo $? 1 $ cat /tmp/pipeline.json Not connected to a TTY, cannot run interactive editor.
I would raise two issues with this:
1. The error message should be sent to STDERR rather than STDOUT especially given that the error has to do with what STDOUT is connected to.
2. It should not be the business of `arv edit` to decide whether or not the editor is going to work when not connected to a TTY. Editors that require a TTY can be expected to print a warning if they aren't going to work, and they are in a much better position to know whether or not they can function usefully without stdout connected to a TTY (many will work just fine). I suggest eliminating this "feature" unless `arv edit` itself has some issue with requiring a TTY (it doesn't seem to).
For example, vim (the only editor I found that actually had a problem with stdout not being connected to a TTY) does print such a warning:
$ vim /tmp/foo > /tmp/bar Vim: Warning: Output is not to a terminal
Emacs does not print a warning, it actually ignores the stdout redirection and connects to the TTY on stdin instead:
$ emacs -nw /tmp/foo > /tmp/bar
Likewise, any X11 editor (including gvim, emacs, etc) would actually work just fine when not connected to a TTY, yet `arv edit` would arbitarily suppress their function.
This limitations prevents one from logging the output when scripting file changes (i.e. using 'ed', 'awk', 'jq', 'perl', etc):
In other words, the following works:
$ echo $',s/foo/bar/g\nw' | EDITOR=ed arv edit 7lnae-p5p6p-ffosu62mxxoky3p 796 796 Updated object 7lnae-p5p6p-ffosu62mxxoky3p
But if you want to record what lines were changed, it would stop working:
$ echo $',s/foo/bar/g\nw' | EDITOR=ed arv edit 7lnae-p5p6p-ffosu62mxxoky3p >> changes.log 796 796 Updated object 7lnae-p5p6p-ffosu62mxxoky3p $ echo $? 1 $ cat changes.log Not connected to a TTY, cannot run interactive editor.
Updated by Joshua Randall over 10 years ago
Updated by Tom Clegg over 10 years ago
- Category set to SDKs
- Status changed from New to Resolved