Skip to content

Commit

Permalink
Do not print xxx when previous command fails (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
certik authored Sep 6, 2024
1 parent 63f0b3c commit 6aac187
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions crates/shell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ async fn interactive() -> anyhow::Result<()> {

let home = dirs::home_dir().context("Couldn't get home directory")?;

let mut prev_exit_code = 0;
let mut _prev_exit_code = 0;
loop {
// Reset cancellation flag
state.reset_cancellation_token();

// Display the prompt and read a line
let readline = if prev_exit_code == 0 {
let readline = {
let cwd = state.cwd().to_string_lossy().to_string();
let home_str = home
.to_str()
Expand All @@ -81,8 +81,6 @@ async fn interactive() -> anyhow::Result<()> {
.map(|stripped| format!("~{}$ ", stripped.replace('\\', "/")))
.unwrap_or_else(|| format!("{}$ ", cwd));
rl.readline(&prompt)
} else {
rl.readline("xxx ")
};

match readline {
Expand All @@ -91,7 +89,7 @@ async fn interactive() -> anyhow::Result<()> {
rl.add_history_entry(line.as_str())?;

// Process the input (here we just echo it back)
prev_exit_code = execute(&line, &mut state)
_prev_exit_code = execute(&line, &mut state)
.await
.context("Failed to execute")?;

Expand Down

0 comments on commit 6aac187

Please sign in to comment.