implemented history for the line editor

This commit is contained in:
2025-05-28 20:24:09 -04:00
parent f67543c111
commit 8cacbfdbdd
8 changed files with 731 additions and 147 deletions

View File

@@ -316,6 +316,7 @@ pub enum ShErrKind {
ParseErr,
InternalErr,
ExecFail,
HistoryReadErr,
ResourceLimitExceeded,
BadPermission,
Errno,
@@ -332,22 +333,23 @@ pub enum ShErrKind {
impl Display for ShErrKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let output = match self {
ShErrKind::IoErr => "I/O Error",
ShErrKind::SyntaxErr => "Syntax Error",
ShErrKind::ParseErr => "Parse Error",
ShErrKind::InternalErr => "Internal Error",
ShErrKind::ExecFail => "Execution Failed",
ShErrKind::ResourceLimitExceeded => "Resource Limit Exceeded",
ShErrKind::BadPermission => "Bad Permissions",
ShErrKind::Errno => "ERRNO",
ShErrKind::FileNotFound(file) => &format!("File not found: {file}"),
ShErrKind::CmdNotFound(cmd) => &format!("Command not found: {cmd}"),
ShErrKind::CleanExit(_) => "",
ShErrKind::FuncReturn(_) => "",
ShErrKind::LoopContinue(_) => "",
ShErrKind::LoopBreak(_) => "",
ShErrKind::ReadlineErr => "Line Read Error",
ShErrKind::Null => "",
Self::IoErr => "I/O Error",
Self::SyntaxErr => "Syntax Error",
Self::ParseErr => "Parse Error",
Self::InternalErr => "Internal Error",
Self::HistoryReadErr => "History Parse Error",
Self::ExecFail => "Execution Failed",
Self::ResourceLimitExceeded => "Resource Limit Exceeded",
Self::BadPermission => "Bad Permissions",
Self::Errno => "ERRNO",
Self::FileNotFound(file) => &format!("File not found: {file}"),
Self::CmdNotFound(cmd) => &format!("Command not found: {cmd}"),
Self::CleanExit(_) => "",
Self::FuncReturn(_) => "",
Self::LoopContinue(_) => "",
Self::LoopBreak(_) => "",
Self::ReadlineErr => "Line Read Error",
Self::Null => "",
};
write!(f,"{output}")
}