[PATCH] histedit: When editing, use `el_set` with `EL_PROMPT_ESC` rather than `EL_PROMPT`.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As can be seen in the `man` page for `el_set`, using `EL_PROMPT_ESC` for
the op is the same as `EL_PROMPT`, but it allows escape characters to be
expanded in the prompt the same way they are when used with `echo` or
`printf(1)`.

As far as I know, this is not specified by POSIX, but neither is the
emacs editing mode (please correct me if I am wrong), so I think this is
a justified change to make it align with the behaviour or `echo` and
`printf(1)`.

Given that this is not specified by POSIX, there isn't much of a
precident for what the value of the start/stop character should be. From
what I have seen, 0o001 is common, so that is what I have included in
the patch, but it may not be the most fitting. Taking a look at how
ASCII defines its control characters, I believe any characters between
0o034 and 0o037 may be a more suitable choice, but this could be up for
debate.

Signed-off-by: Sebastien Peterson-Boudreau
<sebastien.peterson.boudreau@xxxxxxxxx>
---
 src/histedit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/histedit.c b/src/histedit.c
index 7692776..5ab718b 100644
--- a/src/histedit.c
+++ b/src/histedit.c
@@ -115,7 +115,7 @@ histedit(void)
 			if (el != NULL) {
 				if (hist)
 					el_set(el, EL_HIST, history, hist);
-				el_set(el, EL_PROMPT, getprompt);
+				el_set(el, EL_PROMPT_ESC, getprompt, '\1');
 			} else {
 bad:
 				out2str("sh: can't initialize editing\n");
-- 
2.46.0





[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux