To: vim_dev@googlegroups.com Subject: Patch 8.0.1820 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.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) Files: src/os_unix.c, src/testdir/test_terminal.vim *** ../vim-8.0.1819/src/os_unix.c 2018-05-05 21:00:56.804628425 +0200 --- src/os_unix.c 2018-05-12 17:42:33.137113174 +0200 *************** *** 5645,5651 **** /* 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]; channel_set_pipes(channel, in_fd, out_fd, err_fd); channel_set_job(channel, job, options); --- 5645,5656 ---- /* 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 ! ? 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); *** ../vim-8.0.1819/src/testdir/test_terminal.vim 2018-05-06 21:49:28.170020919 +0200 --- src/testdir/test_terminal.vim 2018-05-12 17:38:56.514560377 +0200 *************** *** 1484,1486 **** --- 1484,1508 ---- call feedkeys("\\", '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 *** ../vim-8.0.1819/src/version.c 2018-05-12 17:04:08.892272784 +0200 --- src/version.c 2018-05-12 17:40:42.981847494 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1820, /**/ -- An indication you must be a manager: You can explain to somebody the difference between "re-engineering", "down-sizing", "right-sizing", and "firing people's asses". /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///