Bug 2232155

Summary: There isn't an environment variable to limit the size of .sh_history with ksh
Product: Red Hat Enterprise Linux 8 Reporter: Dave Carmichael <dcarmich>
Component: kshAssignee: Vincent Mihalkovič <vmihalko>
Status: CLOSED NOTABUG QA Contact: Karel Volný <kvolny>
Severity: low Docs Contact:
Priority: unspecified    
Version: 8.8   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-08-16 15:17:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dave Carmichael 2023-08-15 15:59:25 UTC
Description of problem:

With ksh there is no HISTFILESIZE environment variable to limit the size of the history file per the man page. Is this the expected behavior? 

The customer must use logrotate or a cron job to prevent /home from filling up.

Version-Release number of selected component (if applicable):


How reproducible:

Easy


Steps to Reproduce:

1. Set shell to ksh
   usermod -s /bin/ksh dave

2. Set the HISTSIZE variable

     $ env|grep HIST
     HISTCONTROL=ignoredups
     HISTFILESIZE=15
     HISTSIZE=10

3. Run some commands and notice .sh_history continues to grow even though the lines displayed are limited to HISTSIZE setting.

$ history
81	exit
82	ls -l
83	ls -al
84	ls -l .sh_history
85	pwd
86	ls
87	pwd
88	ls -l .sh_history
89	env|grep HIST
90	history



Actual results:

The history file continues to grow.

$ ls -l .sh_history
-rw-------. 1 dave dave 724 Aug 15 11:43 .sh_history
$ pwd
/home/dave
$ ls
$ pwd
/home/dave
$ ls -l .sh_history
-rw-------. 1 dave dave 760 Aug 15 11:43 .sh_history


Expected results:

With bash the .sh_history file stops growing once HISTFILESIZE is reached.

$ ls -l .sh_history
-rw-------. 1 dave dave 888 Aug 15 11:48 .sh_history
[dave@purple ~]$ env|grep HIST
HISTCONTROL=ignoredups
HISTSIZE=10
HISTFILESIZE=12
[dave@purple ~]$ ls -l .sh_history
-rw-------. 1 dave dave 888 Aug 15 11:48 .sh_history

Comment 1 Vincent Mihalkovič 2023-08-16 15:17:15 UTC
Hello,

> With ksh there is no HISTFILESIZE environment variable to limit the size of the history file per the man page. Is this the expected behavior?
Yes, this is expected behavior. There is no remark of a `HISTFILESIZE` variable in the ksh manual pages.

I can report this to upstream as a feature request.