summary refs log tree commit diff
path: root/bin/dash
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/dash/src/dash.16
-rw-r--r--bin/dash/src/histedit.c1
-rw-r--r--bin/dash/src/parser.c15
-rw-r--r--bin/dash/src/parser.h1
-rw-r--r--bin/dash/src/var.c2
-rw-r--r--bin/dash/src/var.h6
6 files changed, 28 insertions, 3 deletions
diff --git a/bin/dash/src/dash.1 b/bin/dash/src/dash.1
index 32f6ac0d..9bc51cd6 100644
--- a/bin/dash/src/dash.1
+++ b/bin/dash/src/dash.1
@@ -32,7 +32,7 @@
 .\"
 .\"	@(#)sh.1	8.6 (Berkeley) 5/4/95
 .\"
-.Dd January 19, 2003
+.Dd December 22, 2020
 .Os
 .Dt DASH 1
 .Sh NAME
@@ -2291,6 +2291,10 @@ The secondary prompt string, which defaults to
 Output before each line when execution trace (set -x) is enabled,
 defaults to
 .Dq +\  .
+.It Ev RPS1
+The primary right prompt string.
+.It Ev RPS2
+The secondary right prompt string.
 .It Ev IFS
 Input Field Separators.
 This is normally set to
diff --git a/bin/dash/src/histedit.c b/bin/dash/src/histedit.c
index 3525e028..58163314 100644
--- a/bin/dash/src/histedit.c
+++ b/bin/dash/src/histedit.c
@@ -116,6 +116,7 @@ histedit(void)
 				if (hist)
 					el_set(el, EL_HIST, history, hist);
 				el_set(el, EL_PROMPT, getprompt);
+				el_set(el, EL_RPROMPT, getrprompt);
 #ifdef HAVE__EL_FN_SH_COMPLETE
 				el_set(el, EL_ADDFN, "sh-complete", "Filename completion",
 					_el_fn_sh_complete);
diff --git a/bin/dash/src/parser.c b/bin/dash/src/parser.c
index 270a01de..21052c21 100644
--- a/bin/dash/src/parser.c
+++ b/bin/dash/src/parser.c
@@ -108,6 +108,7 @@ int quoteflag;			/* set if (part of) last token was quoted */
 
 
 static char *promptcache;
+static char *rpromptcache;
 
 
 STATIC union node *list(int);
@@ -1597,7 +1598,7 @@ STATIC void
 setprompt(int which)
 {
 	struct stackmark smark;
-	const char *prompt;
+	const char *prompt, *rprompt;
 	int show;
 
 	needprompt = 0;
@@ -1607,16 +1608,20 @@ setprompt(int which)
 	default:
 #ifdef DEBUG
 		prompt = "<internal prompt error>";
+		rprompt = prompt;
 		break;
 #endif
 	case 0:
 		prompt = nullstr;
+		rprompt = nullstr;
 		break;
 	case 1:
 		prompt = ps1val();
+		rprompt = rps1val();
 		break;
 	case 2:
 		prompt = ps2val();
+		rprompt = rps2val();
 		break;
 	}
 
@@ -1630,7 +1635,9 @@ setprompt(int which)
 		out2str(expandstr(prompt));
 	} else {
 		free(promptcache);
+		free(rpromptcache);
 		promptcache = savestr(expandstr(prompt));
+		rpromptcache = savestr(expandstr(rprompt));
 	}
 	popstackmark(&smark);
 }
@@ -1644,6 +1651,12 @@ getprompt(void *unused)
 	return promptcache;
 }
 
+const char *
+getrprompt(void *unused)
+{
+	return rpromptcache;
+}
+
 const char *const *
 findkwd(const char *s)
 {
diff --git a/bin/dash/src/parser.h b/bin/dash/src/parser.h
index 524ac1c7..6597faa8 100644
--- a/bin/dash/src/parser.h
+++ b/bin/dash/src/parser.h
@@ -86,6 +86,7 @@ int isassignment(const char *p);
 union node *parsecmd(int);
 void fixredir(union node *, const char *, int);
 const char *getprompt(void *);
+const char *getrprompt(void *);
 const char *const *findkwd(const char *);
 char *endofname(const char *);
 const char *expandstr(const char *);
diff --git a/bin/dash/src/var.c b/bin/dash/src/var.c
index ef9c2bde..ca9504ef 100644
--- a/bin/dash/src/var.c
+++ b/bin/dash/src/var.c
@@ -93,6 +93,8 @@ struct var varinit[] = {
 	{ 0,	VSTRFIXED|VTEXTFIXED,		"PS1=$ ",	0 },
 	{ 0,	VSTRFIXED|VTEXTFIXED,		"PS2=> ",	0 },
 	{ 0,	VSTRFIXED|VTEXTFIXED,		"PS4=+ ",	0 },
+	{ 0,	VSTRFIXED|VTEXTFIXED|VUNSET,	"RPS1\0",	0 },
+	{ 0,	VSTRFIXED|VTEXTFIXED|VUNSET,	"RPS2\0",	0 },
 	{ 0,	VSTRFIXED|VTEXTFIXED,		defoptindvar,	getoptsreset },
 #ifdef WITH_LINENO
 	{ 0,	VSTRFIXED|VTEXTFIXED,		linenovar,	0 },
diff --git a/bin/dash/src/var.h b/bin/dash/src/var.h
index aa7575a7..1d1d87a5 100644
--- a/bin/dash/src/var.h
+++ b/bin/dash/src/var.h
@@ -87,7 +87,9 @@ extern struct var varinit[];
 #define vps1 (&vpath)[1]
 #define vps2 (&vps1)[1]
 #define vps4 (&vps2)[1]
-#define voptind (&vps4)[1]
+#define vrps1 (&vps4)[1]
+#define vrps2 (&vrps1)[1]
+#define voptind (&vrps2)[1]
 #ifdef WITH_LINENO
 #define vlineno (&voptind)[1]
 #endif
@@ -122,6 +124,8 @@ extern char linenovar[];
 #define ps1val()	(vps1.text + 4)
 #define ps2val()	(vps2.text + 4)
 #define ps4val()	(vps4.text + 4)
+#define rps1val()	(vrps1.text + 5)
+#define rps2val()	(vrps2.text + 5)
 #define optindval()	(voptind.text + 7)
 #define linenoval()	(vlineno.text + 7)
 #ifndef SMALL