summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-01-12 15:09:52 -0500
committerJune McEnroe <june@causal.agency>2019-01-12 15:09:52 -0500
commit143c36553e05f3c5d5a4f51cdb6a48116945c525 (patch)
tree3ca5baf984b058db9097c2a51441dace21374ae2 /bin
parentInstall gnupg2 from pkgsrc and symlink gpg (diff)
downloadsrc-143c36553e05f3c5d5a4f51cdb6a48116945c525.tar.gz
src-143c36553e05f3c5d5a4f51cdb6a48116945c525.zip
Set PSlit like NetBSD sh
Diffstat (limited to '')
-rw-r--r--bin/cash/histedit.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/bin/cash/histedit.c b/bin/cash/histedit.c
index 3c77c6e8..92d8170a 100644
--- a/bin/cash/histedit.c
+++ b/bin/cash/histedit.c
@@ -177,10 +177,26 @@ sethistsize(const char *hs)
 }
 
 void
-setpslit(const char *lit) {
-	if (el != NULL && *lit < 0x20) {
-		el_set(el, EL_PROMPT_ESC, getprompt, *lit);
-		el_set(el, EL_RPROMPT_ESC, getrprompt, *lit);
+setpslit(const char *lit_ch) {
+	wchar_t wc;
+
+	if (!(iflag && editing && el))
+		return;
+
+	if (lit_ch == NULL) {
+		el_set(el, EL_PROMPT, getprompt);
+		el_set(el, EL_RPROMPT, getrprompt);
+		return;
+	}
+
+	mbtowc(&wc, NULL, 1);		/* state init */
+
+	if (mbtowc(&wc, lit_ch, strlen(lit_ch)) <= 0) {
+		el_set(el, EL_PROMPT, getprompt);
+		el_set(el, EL_RPROMPT, getrprompt);
+	} else {
+		el_set(el, EL_PROMPT_ESC, getprompt, (int)wc);
+		el_set(el, EL_RPROMPT_ESC, getrprompt, (int)wc);
 	}
 }