Commit: patch 9.2.0921: test: terminal tests fail on FreeBSD

Christian Brabandt <[email protected]> Fri, 7 Aug 2026 22:00:05 +0200
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
patch 9.2.0921: test: terminal tests fail on FreeBSD

Commit: https://github.com/vim/vim/commit/b77d4da3da5c91b2e7ae4bdff606f31a80fb7b7d
Author: neil <[email protected]>
Date:   Fri Aug 7 19:47:24 2026 +0000

    patch 9.2.0921: test: terminal tests fail on FreeBSD
    
    Problem:  terminal test fail on FreeBSD: the shell enables its line
              editor when interactive on a terminal, which echoes the typed
              command a second time and shifts the output down by one line,
              so getline(2) returns "exit" instead of the value.
    Solution: Point $ENV to a startup file that turns the line editor off in
              Run_shell_in_terminal().  POSIX shells read it at startup and
              it produces no output of its own; shells that do not use $ENV
              ignore it (neil).
    
    closes: #20972
    
    Signed-off-by: neil <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/testdir/util/term_util.vim b/src/testdir/util/term_util.vim
index afb44c8db..d36297684 100644
--- a/src/testdir/util/term_util.vim
+++ b/src/testdir/util/term_util.vim
@@ -181,11 +181,29 @@ endfunc
 
 " Open a terminal with a shell, assign the job to g:job and return the buffer
 " number.
+" Some shells turn on a line editor when they are interactive on a
+" terminal; FreeBSD /bin/sh does.  The editor redraws the line the
+" terminal has already echoed, so a command can land in the buffer
+" twice and shift everything below it.  POSIX shells read $ENV at
+" startup and it produces no output of its own; shells that do not
+" use $ENV ignore the variable.
+let s:shell_env_file = ''
+
+func s:ShellStartupFile()
+  if s:shell_env_file == '' || !filereadable(s:shell_env_file)
+    let s:shell_env_file = tempname()
+    call writefile(['set +o emacs 2>/dev/null', 'set +o vi 2>/dev/null'], s:shell_env_file)
+  endif
+  return s:shell_env_file
+endfunc
+
 func Run_shell_in_terminal(options)
   if has('win32')
     let buf = term_start([&shell, '/D', '/k'], a:options)
   else
-    let buf = term_start(&shell, a:options)
+    let options = copy(a:options)
+    let options.env = extend({'ENV': s:ShellStartupFile()}, get(a:options, 'env', {}))
+    let buf = term_start(&shell, options)
   endif
   let g:test_is_flaky = 1
 
diff --git a/src/version.c b/src/version.c
index 674e2fbad..098640446 100644
--- a/src/version.c
+++ b/src/version.c
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    921,
 /**/
     920,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wsQjd-000gm0-Lk%40256bit.org.