]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0921: test: terminal tests fail on FreeBSD v9.2.0921
authorneil <github@neilpang.com>
Fri, 7 Aug 2026 19:47:24 +0000 (19:47 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 7 Aug 2026 19:47:24 +0000 (19:47 +0000)
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 <github@neilpang.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/util/term_util.vim
src/version.c

index afb44c8dbb8ecdcdf62d29206c009ebaa1da4baf..d36297684714f4795d81b11b85fa808d9656b72c 100644 (file)
@@ -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
 
index 674e2fbad559b1c8502f3042d176c331ca4965b4..098640446495025e8c0429d82da96c50d2be8a6b 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    921,
 /**/
     920,
 /**/