fortrangoingonforty/fortsh / e965d9f

Browse files

respect HISTFILE env var at startup, disable in tests

Shell: check HISTFILE env var before loading history file. Previously
always loaded ~/.fortsh_history regardless of HISTFILE setting.

Tests: set HISTFILE=/dev/null in PTY environment to prevent history
file from polluting per-test history. Fixes history test 5 (up arrow
at boundary recalled commands from previous sessions).

Also restore clear_buffer in non-marker sync path to fix history
tests 8, 11, 12.
Authored by espadonne
SHA
e965d9feff4efbf01eb57bccbfc4d9050dbbe12c
Parents
58c634e
Tree
4464160

2 changed files

StatusFile+-
M src/fortsh.f90 11 2
M tests/interactive/fortsh_pty.py 1 0
src/fortsh.f90modified
@@ -168,8 +168,17 @@ program fortran_shell
168168
     ! Set HISTCONTROL for history management
169169
     call set_histcontrol(shell%histcontrol)
170170
 
171
-    ! Load command history from file
172
-    if (len_trim(shell%histfile) > 0) then
171
+    ! Check HISTFILE env var override before loading
172
+    block
173
+      character(len=:), allocatable :: histfile_env
174
+      histfile_env = get_environment_var('HISTFILE')
175
+      if (len(histfile_env) > 0) then
176
+        shell%histfile = histfile_env
177
+      end if
178
+    end block
179
+
180
+    ! Load command history from file (skip if /dev/null)
181
+    if (len_trim(shell%histfile) > 0 .and. trim(shell%histfile) /= '/dev/null') then
173182
       call load_history_from_file(trim(shell%histfile), shell%histsize)
174183
     end if
175184
   end if
tests/interactive/fortsh_pty.pymodified
@@ -68,6 +68,7 @@ class FortshPTY:
6868
         # Note: Completion is NOT disabled here - tests can use Tab completion
6969
         env["FORTSH_MINIMAL_ECHO"] = "1"
7070
         env["FORTSH_TEST_MODE"] = "1"
71
+        env["HISTFILE"] = "/dev/null"  # Don't load/save history from file
7172
 
7273
         # Use /dev/null for clean testing unless specified
7374
         if rc_file is not None: