aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJonas Maier <>2026-03-05 09:15:42 +0100
committerJonas Maier <>2026-03-05 09:15:42 +0100
commit70dd1e194c10904993069c14dbf4642e7a265889 (patch)
tree7863edc06688e17e9c684dacfbab8edf6181edd5 /src/main.rs
parent5e9a2aa9440c1a10b1740b77eb64a3936245c8f2 (diff)
downloadpish-70dd1e194c10904993069c14dbf4642e7a265889.tar.gz
pipe continuations
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 5854272..b0db2e4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -108,6 +108,7 @@ fn main() {
let mut buffer = [0u8; 1];
let mut line = LineBuf::new();
+ let mut history = Vec::new();
print!("{PROMPT}");
@@ -127,6 +128,7 @@ fn main() {
let line = line.dump();
if !line.is_empty() {
print!("\r\n");
+ history.push(line.clone());
run_command(&raw, line);
}
}
@@ -164,6 +166,14 @@ fn main() {
}
}
+ b'|' if line.is_empty() && !history.is_empty() => {
+ let mut cmd = history[history.len()-1].clone();
+ cmd.extend_from_slice(b" | ");
+ io::stdout().write_all(&cmd).unwrap();
+ io::stdout().flush().unwrap();
+ line.set_content(cmd);
+ }
+
// Normal character
x => {
line.add(x);