diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-05-12 17:42:42 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-05-12 17:42:42 +0200 |
commit | cd8fb449d6486a1a5a09c8c098ea3a38c19e8dc5 (patch) | |
tree | 7ac4501460266357e8e294a8e3c115def9647e91 | |
parent | 8c3169c58eef3e04f643fe9e045a97b81429e0cb (diff) | |
download | vim-git-cd8fb449d6486a1a5a09c8c098ea3a38c19e8dc5.tar.gz |
patch 8.0.1820: terminal window redirecting stdout does not show stderrv8.0.1820
Problem: Terminal window redirecting stdout does not show stderr. (Matéo
Zanibelli)
Solution: When stdout is not connected to pty_master_fd then use it for
stderr. (closes #2903)
-rw-r--r-- | src/os_unix.c | 7 | ||||
-rw-r--r-- | src/testdir/test_terminal.vim | 22 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 30 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 495d13475..1609bb8e2 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5645,7 +5645,12 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options) /* When using pty_master_fd only set it for stdout, do not duplicate it * for stderr, it only needs to be read once. */ int err_fd = use_out_for_err || use_file_for_err || use_null_for_err - ? INVALID_FD : fd_err[0] < 0 ? INVALID_FD : fd_err[0]; + ? INVALID_FD + : fd_err[0] >= 0 + ? fd_err[0] + : (out_fd == pty_master_fd + ? INVALID_FD + : pty_master_fd); channel_set_pipes(channel, in_fd, out_fd, err_fd); channel_set_job(channel, job, options); diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 5dfe0275d..14466900a 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -1484,3 +1484,25 @@ func Test_terminal_termwinkey() call feedkeys("\<C-L>\<C-C>", 'tx') call WaitForAssert({-> assert_equal("dead", job_status(job))}) endfunc + +func Test_terminal_out_err() + if !has('unix') + return + endif + call writefile([ + \ '#!/bin/sh', + \ 'echo "this is standard error" >&2', + \ 'echo "this is standard out" >&1', + \ ], 'Xechoerrout.sh') + call setfperm('Xechoerrout.sh', 'rwxrwx---') + + let outfile = 'Xtermstdout' + let buf = term_start(['./Xechoerrout.sh'], {'out_io': 'file', 'out_name': outfile}) + call WaitForAssert({-> assert_inrange(1, 2, len(readfile(outfile)))}) + call assert_equal("this is standard out", readfile(outfile)[0]) + call assert_equal('this is standard error', term_getline(buf, 1)) + + exe buf . 'bwipe' + call delete('Xechoerrout.sh') + call delete(outfile) +endfunc diff --git a/src/version.c b/src/version.c index a6fd36a12..7d86c010e 100644 --- a/src/version.c +++ b/src/version.c @@ -762,6 +762,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1820, +/**/ 1819, /**/ 1818, |