summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortgoodwin <tgoodwin>1998-02-11 14:04:49 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:02 +0100
commit37d2cf03f1f15f57432d3d4fb0c3c451438afdb0 (patch)
tree08c497ec516bf3012d8d209674b1f3da0d853e8e
parent034adee7e777b3f841eebed9fe827689721847c9 (diff)
fix prompting for readline
-rw-r--r--input.c20
-rw-r--r--lex.c10
-rw-r--r--rc.h2
3 files changed, 18 insertions, 14 deletions
diff --git a/input.c b/input.c
index 4524638..d8f19c1 100644
--- a/input.c
+++ b/input.c
@@ -280,10 +280,11 @@ extern Node *doit(bool execit) {
}
if ((s = varlookup("prompt")) != NULL) {
#if READLINE
- prompt = s->w;
-#else
- fprint(2, "%s", s->w);
+ if (istack->fd == 0)
+ prompt = s->w;
+ else
#endif
+ fprint(2, "%s", s->w);
prompt2 = (s->n == NULL ? "" : s->n->w);
}
}
@@ -361,3 +362,16 @@ extern void closefds() {
i->fd = -1;
}
}
+
+extern void print_prompt2() {
+ lineno++;
+ if (interactive) {
+#if READLINE
+ if (istack->fd == 0)
+ prompt = prompt2;
+ else
+#endif
+ fprint(2, "%s", prompt2);
+ }
+}
+
diff --git a/lex.c b/lex.c
index a763ce4..0af7f3f 100644
--- a/lex.c
+++ b/lex.c
@@ -336,16 +336,6 @@ extern void inityy() {
realbuf = ealloc(bufsize);
}
-extern void print_prompt2() {
- lineno++;
-#if READLINE
- prompt = prompt2;
-#else
- if (interactive)
- fprint(2, "%s", prompt2);
-#endif
-}
-
/*
Scan in a pair of integers for redirections like >[2=1]. CLOSED represents a closed file
descriptor (i.e., >[2=]) and UNSET represents an undesignated file descriptor (e.g.,
diff --git a/rc.h b/rc.h
index 0ffb30c..b367325 100644
--- a/rc.h
+++ b/rc.h
@@ -300,6 +300,7 @@ extern int gchar(void);
extern void ugchar(int);
extern Node *doit(bool);
extern void flushu(void);
+extern void print_prompt2(void);
extern void pushfd(int);
extern void pushstring(char **, bool);
extern void popinput(void);
@@ -312,7 +313,6 @@ extern int yylex(void);
extern void inityy(void);
extern void yyerror(const char *);
extern void scanerror(char *);
-extern void print_prompt2(void);
extern const char nw[], dnw[];
/* list.c */