From bf6488ef7c7464406d9d36bed7ae19e32dd4ef05 Mon Sep 17 00:00:00 2001 From: Ruven Salamon Date: Wed, 25 Jan 2023 07:52:28 +0100 Subject: [PATCH] cli: fixes bug where the wrong exit status is reported --- CHANGELOG.md | 1 + avm/src/anchor/main.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d44a18ed51..8e97a02b64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The minor version will be incremented upon a breaking change and the patch versi - cli: Don't regenerate idl in read_all_programs(). ([#2332](https://github.com/coral-xyz/anchor/pull/2332)). - ts: `provider.simulate` will send the transaction with `sigVerify: false` if no `signers` are present ([#2331](https://github.com/coral-xyz/anchor/pull/2331)). +- cli: Failing commands will return the correct exit status. ([#2370](https://github.com/coral-xyz/anchor/pull/2370)). ### Breaking diff --git a/avm/src/anchor/main.rs b/avm/src/anchor/main.rs index 5b6d2e956c..cc3a00cfb0 100644 --- a/avm/src/anchor/main.rs +++ b/avm/src/anchor/main.rs @@ -14,11 +14,15 @@ fn main() -> anyhow::Result<()> { version ); } - Command::new(binary_path) + let exit = Command::new(binary_path) .args(args) .spawn()? .wait_with_output() .expect("Failed to run anchor-cli"); + if !exit.status.success() { + std::process::exit(exit.status.code().unwrap_or(1)); + } + Ok(()) }