Skip to content

Misleading error messages #71

Closed
Closed
@TheButlah

Description

@TheButlah

The error messages cmd_lib gives don't seem as intuitive as bash. Consider the following code:

fn main() -> color_eyre::Result<()> {
    color_eyre::install()?;

    let log_to_find = "evilevil";
    cmd_lib::run_cmd! {
        info "this is a log message";
        pwd;
        cat log.txt | grep $log_to_find;
    }?;

    Ok(())
}

This produces this error:

❯ cargo run
   Compiling foo v0.0.0 (/Users/ryan.butler/P/scratch/foo)
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/foo`
[INFO ] this is a log message
/Users/ryan.butler/P/scratch
[INFO ] cat: log.txt: No such file or directory
Error:
   0: Running ["grep" "evilevil"] exited with error; status code: 1 at foo/src/main.rs:5

Location:
   foo/src/main.rs:5

But in bash, I get:

❯ cat log.txt | grep evilevil
cat: log.txt: No such file or directory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions