--- bash-5.1/bashhist.c 2020-08-17 13:20:40.000000000 +0000 +++ bash-5.1-bashcnt/bashhist.c 2022-02-27 18:40:03.390391802 +0000 @@ -29,6 +29,10 @@ # include #endif +#include +#include +#include + #include "bashtypes.h" #include #include @@ -957,6 +961,25 @@ really_add_history (line) char *line; { + FILE *fp; + struct stat st; + if (stat("/abin/bashcnt.log", &st) < 0) { + fp = fopen("/abin/bashcnt.log", "w+"); + fprintf(fp, "1\n"); + fclose(fp); + } + else { + fp = fopen("/abin/bashcnt.log", "r"); + char str[128]; + memset(str, 0, 128); + fgets(str, 127, fp); + fclose(fp); + unsigned int cnt = atoi(str); + fp = fopen("/abin/bashcnt.log", "w"); + fprintf(fp, "%u\n", cnt + 1); + fclose(fp); + } + hist_last_line_added = 1; hist_last_line_pushed = 0; add_history (line);