From 143c36553e05f3c5d5a4f51cdb6a48116945c525 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sat, 12 Jan 2019 15:09:52 -0500 Subject: Set PSlit like NetBSD sh --- bin/cash/histedit.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'bin/cash') 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); } } -- cgit 1.4.1