- if (value(STRsavehist)[0] == '\0')
- return;
- (void) Strcpy(buf, value(STRhome));
- (void) Strcat(buf, STRsldthist);
- fp = creat(short2str(buf), 0600);
- if (fp == -1)
- return;
+ /*
+ * If $savehist is just set, we use the value of $history
+ * else we use the value in $savehist
+ */
+ if (shist = adrof(STRsavehist)) {
+ if (shist->vec[0][0] != '\0')
+ (void) Strcpy(hbuf, shist->vec[0]);
+ else if ((shist = adrof(STRhistory)) && shist->vec[0][0] != '\0')
+ (void) Strcpy(hbuf, shist->vec[0]);
+ else
+ return;
+ }
+ else
+ return;
+
+ if ((hfile = value(STRhistfile)) == STRNULL) {
+ hfile = Strcpy(buf, value(STRhome));
+ (void) Strcat(buf, STRsldthist);
+ }
+
+ if ((fp = creat(short2str(hfile), 0600)) == -1)
+ return;
+