Phase 5: Ausführung und Output implementieren und archivieren

This commit is contained in:
2026-09-06 18:56:47 +02:00
parent 9c85349a4d
commit e3dc9028bf
37 changed files with 2404 additions and 450 deletions

View File

@@ -1668,44 +1668,23 @@ fn bi_lpos(
Ok(Some(Value::Int(spalte as i16 + 1)))
}
/// Gemeinsamer Kern von `SHELL` als Anweisung und als Funktion.
fn shell_ausfuehren(befehl: &str) -> Result<i32, RuntimeError> {
let mut cmd = if cfg!(windows) {
let mut c = std::process::Command::new("cmd");
c.args(["/C", befehl]);
c
} else {
let mut c = std::process::Command::new("sh");
c.args(["-c", befehl]);
c
};
cmd.status()
.map(|s| s.code().unwrap_or(0))
.map_err(|_| RuntimeError(53))
}
fn bi_shell_stmt(
_: &mut RtState,
_: &mut dyn Host,
host: &mut dyn Host,
a: &mut [Value],
) -> Result<Option<Value>, RuntimeError> {
let befehl = match a.first() {
Some(Value::Str(s)) => s.to_string(),
_ => String::new(),
let command = match a.first() {
Some(Value::Str(s)) => s.as_ref(),
_ => "",
};
if befehl.is_empty() {
return Ok(None);
}
shell_ausfuehren(&befehl).map(|_| None)
host.shell(command).map(|_| None)
}
fn bi_shell_fn(
_: &mut RtState,
_: &mut dyn Host,
host: &mut dyn Host,
a: &mut [Value],
) -> Result<Option<Value>, RuntimeError> {
let code = shell_ausfuehren(&arg_str(a, 0)?)?;
Ok(Some(Value::Lng(code)))
host.shell(&arg_str(a, 0)?).map(|code| code.map(Value::Lng))
}
/// `MKI$`/`MKL$`/`MKS$`/`MKD$`/`MKC$` — Zahl in ihre Bytedarstellung.