Page MenuHomeFreeBSD

Only initialize libedit and history when in interactive mode.
ClosedPublic

Authored by jmmv on Jun 28 2015, 4:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 11, 2:11 AM
Unknown Object (File)
Fri, Oct 10, 4:07 AM
Unknown Object (File)
Tue, Oct 7, 1:55 AM
Unknown Object (File)
Mon, Oct 6, 6:54 PM
Unknown Object (File)
Mon, Oct 6, 4:41 PM
Unknown Object (File)
Sep 13 2025, 2:39 PM
Unknown Object (File)
Sep 12 2025, 10:43 PM
Unknown Object (File)
Aug 16 2025, 2:50 PM
Subscribers

Details

Summary

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.

Test Plan

Run the command above to see that the "staircase effect"
described in the PR is not a problem any longer. Also run the basics_test
test program to see that the terminal output is sane.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage

Event Timeline

jmmv retitled this revision from to Only initialize libedit and history when in interactive mode..
jmmv updated this object.
jmmv edited the test plan for this revision. (Show Details)
jmmv added a reviewer: eadler.

perhaps it would be better to hide libedit init under isatty instead of specific command line flags?

I don't think so. That code path uses el_gets() unconditionally so we need libedit to be initialized. Not using libedit if not a tty would be out of scope for this change, and a larger change.

eadler edited edge metadata.
This revision is now accepted and ready to land.Jun 28 2015, 4:31 PM