From owner-svn-src-head@freebsd.org Sat Aug 8 10:38:39 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 026BB9B507B; Sat, 8 Aug 2015 10:38:39 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.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 E78CB13DC; Sat, 8 Aug 2015 10:38:38 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t78Acc7o083176; Sat, 8 Aug 2015 10:38:38 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t78AccbQ083175; Sat, 8 Aug 2015 10:38:38 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201508081038.t78AccbQ083175@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sat, 8 Aug 2015 10:38:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286446 - 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: Sat, 08 Aug 2015 10:38:39 -0000 Author: trasz Date: Sat Aug 8 10:38:37 2015 New Revision: 286446 URL: https://svnweb.freebsd.org/changeset/base/286446 Log: Fix interaction between libedit initialization and Capsicum in units(1). The most visible is the removal of libedit warnings about being unable to open termcap database. Reviewed by: eadler@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3322 Modified: head/usr.bin/units/units.c Modified: head/usr.bin/units/units.c ============================================================================== --- head/usr.bin/units/units.c Sat Aug 8 09:57:38 2015 (r286445) +++ head/usr.bin/units/units.c Sat Aug 8 10:38:37 2015 (r286446) @@ -802,10 +802,10 @@ main(int argc, char **argv) if (!readfile) readunits(NULL); - if (cap_enter() < 0 && errno != ENOSYS) - err(1, "unable to enter capability mode"); - if (optind == argc - 2) { + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + havestr = argv[optind]; wantstr = argv[optind + 1]; initializeunit(&have); @@ -815,8 +815,7 @@ main(int argc, char **argv) addunit(&want, wantstr, 0, 1); completereduce(&want); showanswer(&have, &want); - } - else { + } else { inhistory = history_init(); el = el_init(argv[0], stdin, stdout, stderr); el_set(el, EL_PROMPT, &prompt); @@ -828,6 +827,9 @@ main(int argc, char **argv) if (inhistory == 0) err(1, "Could not initialize history"); + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + if (!quiet) printf("%d units, %d prefixes\n", unitcount, prefixcount);