summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2015-08-08 10:38:37 +0000
committertrasz <trasz@FreeBSD.org>2015-08-08 10:38:37 +0000
commit0fe044d6fdac6f0bb562cc7c9cc5d13038425034 (patch)
tree94422ccb5e717ed16bafb8dd1514449d0ff38a22
parentf1eded629ea42098936bff4daa853471c65cc765 (diff)
downloadFreeBSD-src-0fe044d6fdac6f0bb562cc7c9cc5d13038425034.zip
FreeBSD-src-0fe044d6fdac6f0bb562cc7c9cc5d13038425034.tar.gz
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
-rw-r--r--usr.bin/units/units.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/units/units.c b/usr.bin/units/units.c
index 929510f..94495c9 100644
--- a/usr.bin/units/units.c
+++ b/usr.bin/units/units.c
@@ -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);
OpenPOWER on IntegriCloud