You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error messages cmd_lib gives don't seem as intuitive as bash. Consider the following code:
fnmain() -> 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
The text was updated successfully, but these errors were encountered:
The truth is that: the error was indeed from grep, even in bash (w/ or w/o pipefail):
$ ls /xx | grep y
ls: cannot access '/xx': No such file or directory
$ echo $?
1
$ ls /xx
ls: cannot access '/xx': No such file or directory
$ echo $?
2
$ echo /xx | grep y
$ echo $?
1
$ set -o pipefail
$ ls /xx | grep y
ls: cannot access '/xx': No such file or directory
$ echo $?
1
We have also logged the stderr output, so you can find out why it caused the grep to fail. Note ideally the log level should be WARN/ERROR, however the library only knows there was information from stderr and they are OK in most of the cases.
The error messages cmd_lib gives don't seem as intuitive as bash. Consider the following code:
This produces this error:
But in bash, I get:
The text was updated successfully, but these errors were encountered: