Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Mar 2019 21:53:44 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r345613 - stable/12/bin/sh
Message-ID:  <201903272153.x2RLrifl057012@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Wed Mar 27 21:53:44 2019
New Revision: 345613
URL: https://svnweb.freebsd.org/changeset/base/345613

Log:
  MFC r344306: sh: Send normal output from bind builtin to stdout
  
  PR:		233343

Modified:
  stable/12/bin/sh/histedit.c
  stable/12/bin/sh/output.c
  stable/12/bin/sh/output.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/bin/sh/histedit.c
==============================================================================
--- stable/12/bin/sh/histedit.c	Wed Mar 27 21:50:07 2019	(r345612)
+++ stable/12/bin/sh/histedit.c	Wed Mar 27 21:53:44 2019	(r345613)
@@ -474,10 +474,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

Modified: stable/12/bin/sh/output.c
==============================================================================
--- stable/12/bin/sh/output.c	Wed Mar 27 21:50:07 2019	(r345612)
+++ stable/12/bin/sh/output.c	Wed Mar 27 21:53:44 2019	(r345613)
@@ -340,6 +340,12 @@ doformat(struct output *dest, const char *f, va_list a
 	}
 }
 
+FILE *
+out1fp(void)
+{
+	return fwopen(out1, doformat_wr);
+}
+
 /*
  * Version of write which resumes after a signal is caught.
  */

Modified: stable/12/bin/sh/output.h
==============================================================================
--- stable/12/bin/sh/output.h	Wed Mar 27 21:50:07 2019	(r345612)
+++ stable/12/bin/sh/output.h	Wed Mar 27 21:53:44 2019	(r345613)
@@ -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)))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903272153.x2RLrifl057012>