summary refs log tree commit diff
path: root/bin/cash/histedit.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-01-15 23:37:38 -0500
committerJune McEnroe <june@causal.agency>2019-01-15 23:37:38 -0500
commite9f521762addffe2532868082bc165ca53adb167 (patch)
treec0f54610fca1048a989a523cafb0965c1c2292c9 /bin/cash/histedit.c
parentAdd !! alias in cash (diff)
downloadsrc-e9f521762addffe2532868082bc165ca53adb167.tar.gz
src-e9f521762addffe2532868082bc165ca53adb167.zip
Add basic HISTFILE load and save
Diffstat (limited to 'bin/cash/histedit.c')
-rw-r--r--bin/cash/histedit.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/cash/histedit.c b/bin/cash/histedit.c
index d1e77f51..156800a1 100644
--- a/bin/cash/histedit.c
+++ b/bin/cash/histedit.c
@@ -146,12 +146,19 @@ bad:
 			el_source(el, NULL);
 		}
 	} else {
+		HistEvent he;
+		const char *hf;
+
 		INTOFF;
 		if (el) {	/* no editing if not interactive */
 			el_end(el);
 			el = NULL;
 		}
 		if (hist) {
+			hf = lookupvar("HISTFILE");
+			if (hf != NULL && *hf != '\0')
+				if (history(hist, &he, H_SAVE, hf) == -1)
+					out2fmt_flush("sh: can't save history\n");
 			history_end(hist);
 			hist = NULL;
 		}
@@ -161,6 +168,15 @@ bad:
 
 
 void
+sethistfile(const char *hf)
+{
+	HistEvent he;
+
+	if (hist != NULL && hf != NULL && *hf != '\0')
+		history(hist, &he, H_LOAD, hf);
+}
+
+void
 sethistsize(const char *hs)
 {
 	int histsize;