diff options
Diffstat (limited to '')
-rw-r--r-- | bin/cash/histedit.c | 24 |
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); } } |