From owner-svn-src-head@freebsd.org Sun Jun 28 16:43:08 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 47B4F98F79B; Sun, 28 Jun 2015 16:43:08 +0000 (UTC) (envelope-from jmmv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18DB51D07; Sun, 28 Jun 2015 16:43:08 +0000 (UTC) (envelope-from jmmv@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5SGh7JO009455; Sun, 28 Jun 2015 16:43:07 GMT (envelope-from jmmv@FreeBSD.org) Received: (from jmmv@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5SGh7D9009454; Sun, 28 Jun 2015 16:43:07 GMT (envelope-from jmmv@FreeBSD.org) Message-Id: <201506281643.t5SGh7D9009454@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jmmv set sender to jmmv@FreeBSD.org using -f From: Julio Merino Date: Sun, 28 Jun 2015 16:43:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284912 - head/usr.bin/units X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2015 16:43:08 -0000 Author: jmmv Date: Sun Jun 28 16:43:07 2015 New Revision: 284912 URL: https://svnweb.freebsd.org/changeset/base/284912 Log: Only initialize libedit when necessary The code path to support units conversions from the command line need not initialize neither libedit nor the history. Therefore, only do that when in interactive mode. This hides the issue reported in PR bin/201167 whereby running commands of the form 'echo "$(units ft in)"' would corrupt the terminal. The real issue causing the corruption most likely still remains somewhere. PR: bin/201167 Differential Revision: D2935 Reviewed by: eadler Modified: head/usr.bin/units/units.c Modified: head/usr.bin/units/units.c ============================================================================== --- head/usr.bin/units/units.c Sun Jun 28 12:52:28 2015 (r284911) +++ head/usr.bin/units/units.c Sun Jun 28 16:43:07 2015 (r284912) @@ -802,17 +802,6 @@ main(int argc, char **argv) if (!readfile) readunits(NULL); - inhistory = history_init(); - el = el_init(argv[0], stdin, stdout, stderr); - el_set(el, EL_PROMPT, &prompt); - el_set(el, EL_EDITOR, "emacs"); - el_set(el, EL_SIGNAL, 1); - el_set(el, EL_HIST, history, inhistory); - el_source(el, NULL); - history(inhistory, &ev, H_SETSIZE, 800); - if (inhistory == 0) - err(1, "Could not initialize history"); - if (cap_enter() < 0 && errno != ENOSYS) err(1, "unable to enter capability mode"); @@ -828,6 +817,17 @@ main(int argc, char **argv) showanswer(&have, &want); } else { + inhistory = history_init(); + el = el_init(argv[0], stdin, stdout, stderr); + el_set(el, EL_PROMPT, &prompt); + el_set(el, EL_EDITOR, "emacs"); + el_set(el, EL_SIGNAL, 1); + el_set(el, EL_HIST, history, inhistory); + el_source(el, NULL); + history(inhistory, &ev, H_SETSIZE, 800); + if (inhistory == 0) + err(1, "Could not initialize history"); + if (!quiet) printf("%d units, %d prefixes\n", unitcount, prefixcount); @@ -858,9 +858,10 @@ main(int argc, char **argv) completereduce(&want)); showanswer(&have, &want); } + + history_end(inhistory); + el_end(el); } - history_end(inhistory); - el_end(el); return (0); }