Interface Expander
-
- All Known Implementing Classes:
DefaultExpander
public interface Expander
The Expander interface provides functionality for expanding special syntax in command lines.Expanders are responsible for processing and expanding various types of expressions in the input line before it is executed. This includes:
- History expansions (e.g., !! to repeat the last command)
- Variable expansions (e.g., $HOME or ${HOME})
- Other shell-like expansions
The expander is called by the LineReader after the user has accepted a line but before it is executed or added to the history. This allows the user to see the unexpanded form while editing, but ensures that the expanded form is what gets executed and stored in history.
The default implementation is
DefaultExpander
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
expandHistory(History history, java.lang.String line)
Expands history references in the input line.java.lang.String
expandVar(java.lang.String word)
Expands variables in the input word.
-
-
-
Method Detail
-
expandHistory
java.lang.String expandHistory(History history, java.lang.String line)
Expands history references in the input line.This method processes history designators such as !!, !$, !n, etc., replacing them with the corresponding entries from the command history.
- Parameters:
history
- the command history to use for expansionline
- the input line containing history references- Returns:
- the line with history references expanded
-
expandVar
java.lang.String expandVar(java.lang.String word)
Expands variables in the input word.This method processes variable references such as $VAR or ${VAR}, replacing them with their values. The specific syntax and behavior depends on the implementation.
- Parameters:
word
- the word containing variable references- Returns:
- the word with variables expanded
-
-