summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2019-02-19 21:27:30 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2019-02-19 21:27:30 +0000
commit94b793c49790cdb4f945fe909c65d4c89fe71f16 (patch)
tree633b8b2b2d334411c9ff5edcc91d05c06911b023 /bin
parent60a92c781da2d6e1cc61fb5a9d759f15bb42c287 (diff)
downloadsrc-test2-94b793c49790cdb4f945fe909c65d4c89fe71f16.tar.gz
src-test2-94b793c49790cdb4f945fe909c65d4c89fe71f16.zip
sh: Send normal output from bind builtin to stdout
PR: 233343 Submitted by: Yuichiro NAITO (original version)
Notes
Notes: svn path=/head/; revision=344306
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/histedit.c23
-rw-r--r--bin/sh/output.c6
-rw-r--r--bin/sh/output.h2
3 files changed, 30 insertions, 1 deletions
diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c
index 62f5a89a05e1..1a603317627d 100644
--- a/bin/sh/histedit.c
+++ b/bin/sh/histedit.c
@@ -472,10 +472,31 @@ str_to_event(const char *str, int last)
int
bindcmd(int argc, char **argv)
{
+ int ret;
+ FILE *old;
+ FILE *out;
if (el == NULL)
error("line editing is disabled");
- return (el_parse(el, argc, __DECONST(const char **, argv)));
+
+ INTOFF;
+
+ out = out1fp();
+ if (out == NULL)
+ error("Out of space");
+
+ el_get(el, EL_GETFP, 1, &old);
+ el_set(el, EL_SETFP, 1, out);
+
+ ret = el_parse(el, argc, __DECONST(const char **, argv));
+
+ el_set(el, EL_SETFP, 1, old);
+
+ fclose(out);
+
+ INTON;
+
+ return ret;
}
#else
diff --git a/bin/sh/output.c b/bin/sh/output.c
index 00077a1dc072..c01ddd5acb83 100644
--- a/bin/sh/output.c
+++ b/bin/sh/output.c
@@ -340,6 +340,12 @@ doformat(struct output *dest, const char *f, va_list ap)
}
}
+FILE *
+out1fp(void)
+{
+ return fwopen(out1, doformat_wr);
+}
+
/*
* Version of write which resumes after a signal is caught.
*/
diff --git a/bin/sh/output.h b/bin/sh/output.h
index 25b01a5896e7..62f006d32a36 100644
--- a/bin/sh/output.h
+++ b/bin/sh/output.h
@@ -39,6 +39,7 @@
#include <stdarg.h>
#include <stddef.h>
+#include <stdio.h>
struct output {
char *nextc;
@@ -75,6 +76,7 @@ void out1fmt(const char *, ...) __printflike(1, 2);
void out2fmt_flush(const char *, ...) __printflike(1, 2);
void fmtstr(char *, int, const char *, ...) __printflike(3, 4);
void doformat(struct output *, const char *, va_list) __printflike(2, 0);
+FILE *out1fp(void);
int xwrite(int, const char *, int);
#define outc(c, file) ((file)->nextc == (file)->bufend ? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))