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
This commit is contained in:
parent
be1eea0753
commit
619e4f78fe
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user