Replace native GNU readline with JLine (#5)#134
Open
cansin wants to merge 3 commits into
Open
Conversation
Pin down the existing behaviour of the StreamReadline fallback and the stable LineInput.getStreamReadline factory before migrating the interactive input from the native GNU readline library to JLine. These tests pass against the current implementation and act as a regression safety net for the upcoming change. https://claude.ai/code/session_01Dve366yx4bjiFecJpbsZ7q
Resolves useocl#5. USE's interactive command line previously relied on the native Unix GNU readline library through a JNI binding (GNUReadline + natGNUReadline.c), which required a platform-dependent native build step and was effectively unavailable on Windows. Replace it with the pure-Java JLine library (already a declared dependency), giving line editing and a persistent command history on Linux, macOS and Windows with no native build steps. - Add JLineReadline, a Readline implementation backed by JLine's ConsoleReader with a FileHistory. History expansion is disabled so the SOIL '!' / '!!' commands are passed through verbatim. - LineInput.getUserInputReadline() now returns the JLine implementation for interactive terminals and falls back to the existing StreamReadline when no console is available (piped/headless), preserving current non-interactive behaviour. - Remove the JNI GNUReadline class and the natGNUReadline.c native source; declare the jline module in module-info. - Drop the obsolete "GNU readline not available" warning from the shell. The -nr command line switch is kept as an accepted no-op for backward compatibility (it is still passed by the Windows launcher and tests). - Cover the new behaviour with JLineReadlineTest and an additional LineInput test; the StreamReadline safety net continues to pass. https://claude.ai/code/session_01Dve366yx4bjiFecJpbsZ7q
Reflect the move from the native GNU readline library to the pure-Java JLine library: - INSTALL: describe JLine-based line editing/history; no native build step. - README: list JLine among the bundled third-party libraries. - NEWS: add an entry for the readline -> JLine change. - bin/use: drop LD_LIBRARY_PATH, which only existed for the native readline library. - bin/start_use.bat: drop the now-obsolete -nr switch (the missing readline warning it suppressed no longer exists). - .gitignore: ignore the .claude directory. https://claude.ai/code/session_01Dve366yx4bjiFecJpbsZ7q
Collaborator
|
Very nice, I would love to review this asap. I also found this problem while working on my PR, which I hadn't fixed due to not relevant to the PR itself. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace native GNU readline with JLine
Closes #5.
Motivation
USE's interactive command line relied on the native Unix GNU readline
library via a JNI binding (
GNUReadline+natGNUReadline.c). This required aplatform-dependent native compilation step as part of the build and was
effectively unavailable on Windows, so most users silently fell back to a bare
input stream with no line editing or history.
This PR replaces that with the pure-Java JLine
library — which was already declared as a dependency but never wired up —
giving line editing and a persistent command history on Linux, macOS and
Windows with no native build steps.
What changed
JLineReadline— aReadlineimplementation backed by JLine'sConsoleReaderwith aFileHistory. History expansion is disabled so theSOIL
!/!!commands are passed through verbatim.LineInput.getUserInputReadline()now returns the JLine implementationfor interactive terminals and falls back to the existing
StreamReadlinewhen no console is available (piped/headless), preserving current
non-interactive behaviour.
GNUReadlineclass and thenatGNUReadline.cnativesource, and the
System.loadLibrarycall; declared thejlinemodule inmodule-info.The
-nrcommand-line switch is kept as an accepted no-op for backwardcompatibility (it is still passed by the Windows launcher and the integration
tests, and unknown flags abort startup).
INSTALL,README, andNEWS; removed thenative-only
LD_LIBRARY_PATHfrombin/useand the now-obsolete-nrfrombin/start_use.bat.Behaviour & compatibility
(
~/.use_history) on all platforms.StreamReadline).jline:jline:2.14.6was already on theclasspath.
Testing
Developed test-first (red → green) with a regression safety net:
StreamReadline/LineInputbehaviour and confirmed they pass against the current implementation.
JLineReadlineTestand aLineInputfactory test for the newbehaviour (red before the change).
Verified locally:
use-coreunit tests: greenuse-guiunit tests: greenShellITend-to-end shell integration suite: 129 tests, 0 failures(exercises real command files in-process and confirms
-nrstill works)