Added use of $CALCHISTFILE and start of 2.12.7.5

By default, the calc history file is located in ~/.calc_history.
Now, if the environment variable $CALCHISTFILE is defined
and is non-empty, then calc history file will be defined
by the $CALCHISTFILE environment variable.
This commit is contained in:
Landon Curt Noll
2021-02-03 00:51:56 -08:00
parent a8be58becb
commit 41803b878e
11 changed files with 89 additions and 33 deletions

View File

@@ -145,6 +145,7 @@ char *calcbindings = NULL; /* $CALCBINDINGS or default */
char *home = NULL; /* $HOME or default */
char *pager = NULL; /* $PAGER or default */
char *shell = NULL; /* $SHELL or default */
char *calc_history = NULL; /* $CALCHISTFILE or ~/.calc_history */
int stdin_tty = FALSE; /* TRUE if stdin is a tty */
int havecommands = FALSE; /* TRUE if have one or more cmd args */
long stoponerror = 0; /* >0 => stop, <0 => continue, ==0 => use -c */
@@ -546,6 +547,12 @@ initenv(void)
shell = (c ? strdup(c) : NULL);
if (shell == NULL || *shell == '\0')
shell = DEFAULTSHELL;
/* determine the $CALCHISTFILE value */
c = (no_env ? NULL : getenv(CALCHISTFILE));
calc_history = (c ? strdup(c) : NULL);
if (calc_history == NULL || *calc_history == '\0')
calc_history = NULL; /* will use ~/.calc_history */
}