Index: bin/sh/histedit.c =================================================================== --- bin/sh/histedit.c (revision 342855) +++ bin/sh/histedit.c (working copy) @@ -474,10 +474,36 @@ int bindcmd(int argc, char **argv) { + int ret; + FILE *old1, *old2; + FILE *out1, *out2; if (el == NULL) error("line editing is disabled"); - return (el_parse(el, argc, __DECONST(const char **, argv))); + + /* get output FILE pointers */ + out1 = out1fp(); + out2 = out2fp(); + + /* backup current FILE pointers */ + el_get(el, EL_GETFP, 1, &old1); + el_get(el, EL_GETFP, 2, &old2); + + /* set command output FILE pointers */ + el_set(el, EL_SETFP, 1, out1); + el_set(el, EL_SETFP, 2, out2); + + ret = el_parse(el, argc, __DECONST(const char **, argv)); + + /* restore old FILE pointer */ + el_set(el, EL_SETFP, 1, old1); + el_set(el, EL_SETFP, 2, old2); + + /* close command outputs */ + fclose(out1); + fclose(out2); + + return ret; } #else Index: bin/sh/output.c =================================================================== --- bin/sh/output.c (revision 342855) +++ bin/sh/output.c (working copy) @@ -340,6 +340,16 @@ } } +FILE * +out1fp() { + return fwopen(out1, doformat_wr); +} + +FILE * +out2fp() { + return fwopen(out2, doformat_wr); +} + /* * Version of write which resumes after a signal is caught. */ Index: bin/sh/output.h =================================================================== --- bin/sh/output.h (revision 342855) +++ bin/sh/output.h (working copy) @@ -37,6 +37,7 @@ #ifndef OUTPUT_INCL +#include #include #include @@ -75,6 +76,8 @@ 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(); +FILE *out2fp(); int xwrite(int, const char *, int); #define outc(c, file) ((file)->nextc == (file)->bufend ? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))