summary refs log tree commit diff
path: root/bin/1sh/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/1sh/parser.c')
-rw-r--r--bin/1sh/parser.c84
1 files changed, 58 insertions, 26 deletions
diff --git a/bin/1sh/parser.c b/bin/1sh/parser.c
index 97d6f52a..b92b9462 100644
--- a/bin/1sh/parser.c
+++ b/bin/1sh/parser.c
@@ -1969,35 +1969,11 @@ pgetc_linecont(void)
 	return (c);
 }
 
-/*
- * called by editline -- any expansions to the prompt
- *    should be added here.
- */
-char *
-getprompt(void *unused __unused)
-{
+static char *
+expandprompt(const char *fmt) {
 	static char ps[PROMPTLEN];
-	const char *fmt;
 	const char *pwd;
 	int i, trim;
-	static char internal_error[] = "??";
-
-	/*
-	 * Select prompt format.
-	 */
-	switch (whichprompt) {
-	case 0:
-		fmt = "";
-		break;
-	case 1:
-		fmt = ps1val();
-		break;
-	case 2:
-		fmt = ps2val();
-		break;
-	default:
-		return internal_error;
-	}
 
 	/*
 	 * Format prompt string.
@@ -2077,6 +2053,62 @@ getprompt(void *unused __unused)
 	return (ps);
 }
 
+/*
+ * called by editline -- any expansions to the prompt
+ *    should be added here.
+ */
+char *
+getprompt(void *unused __unused)
+{
+	const char *fmt;
+	static char internal_error[] = "??";
+
+	/*
+	 * Select prompt format.
+	 */
+	switch (whichprompt) {
+	case 0:
+		fmt = "";
+		break;
+	case 1:
+		fmt = ps1val();
+		break;
+	case 2:
+		fmt = ps2val();
+		break;
+	default:
+		return internal_error;
+	}
+
+	return expandprompt(fmt);
+}
+
+char *
+getrprompt(void *unused __unused)
+{
+	const char *fmt;
+	static char internal_error[] = "??";
+
+	/*
+	 * Select prompt format.
+	 */
+	switch (whichprompt) {
+	case 0:
+		fmt = "";
+		break;
+	case 1:
+		fmt = rps1val();
+		break;
+	case 2:
+		fmt = rps2val();
+		break;
+	default:
+		return internal_error;
+	}
+
+	return expandprompt(fmt);
+}
+
 
 const char *
 expandstr(const char *ps)