From 2cb4357039a7adf0854c4d049c60a2b13d0941c5 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 8 Mar 2012 08:20:09 +0000 Subject: allow editline in -d mode; from AIDA Shinra --- usr.bin/bc/bc.y | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'usr.bin/bc/bc.y') diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y index 1499a94ba94..aabcbff4228 100644 --- a/usr.bin/bc/bc.y +++ b/usr.bin/bc/bc.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: bc.y,v 1.40 2011/10/06 14:37:56 otto Exp $ */ +/* $OpenBSD: bc.y,v 1.41 2012/03/08 08:20:08 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek @@ -1144,19 +1144,6 @@ main(int argc, char *argv[]) dup(p[1]); close(p[0]); close(p[1]); - if (interactive) { - gettty(&ttysaved); - el = el_init("bc", stdin, stderr, stderr); - hist = history_init(); - history(hist, &he, H_SETSIZE, 100); - el_set(el, EL_HIST, history, hist); - el_set(el, EL_EDITOR, "emacs"); - el_set(el, EL_SIGNAL, 0); - el_set(el, EL_PROMPT, dummy_prompt); - el_set(el, EL_ADDFN, "bc_eof", "", bc_eof); - el_set(el, EL_BIND, "^D", "bc_eof", NULL); - el_source(el, NULL); - } } else { close(STDIN_FILENO); dup(p[0]); @@ -1166,6 +1153,19 @@ main(int argc, char *argv[]) err(1, "cannot find dc"); } } + if (interactive) { + gettty(&ttysaved); + el = el_init("bc", stdin, stderr, stderr); + hist = history_init(); + history(hist, &he, H_SETSIZE, 100); + el_set(el, EL_HIST, history, hist); + el_set(el, EL_EDITOR, "emacs"); + el_set(el, EL_SIGNAL, 0); + el_set(el, EL_PROMPT, dummy_prompt); + el_set(el, EL_ADDFN, "bc_eof", "", bc_eof); + el_set(el, EL_BIND, "^D", "bc_eof", NULL); + el_source(el, NULL); + } yywrap(); return yyparse(); } -- cgit v1.2.3