Skip to content

Commit

Permalink
fix: handle exec() errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeidnx committed Dec 20, 2024
1 parent 8f759a8 commit cad11e4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn run_command_or_open_shell(
command: &str,
trail: &[String],
nixpkgs_flake: &str,
) {
) -> ! {
let mut run_cmd = Command::new("nix");

run_cmd.args([
Expand All @@ -114,7 +114,8 @@ fn run_command_or_open_shell(
}
};

run_cmd.exec();
let res = run_cmd.exec();
panic!("Failed to exec: {res}");
}

fn main() -> ExitCode {
Expand Down Expand Up @@ -199,6 +200,7 @@ fn main() -> ExitCode {
Command::new("nix-env")
.args(["-f", "<nixpkgs>", "-iA", basename])
.exec();
ExitCode::SUCCESS
} else if args.print_path {
run_command_or_open_shell(
use_channel,
Expand All @@ -219,8 +221,6 @@ fn main() -> ExitCode {
&args.nixpkgs_flake,
);
}

ExitCode::SUCCESS
}

fn open_shell(
Expand Down Expand Up @@ -251,7 +251,6 @@ fn open_shell(
&[],
nixpkgs_flake.as_str(),
);
ExitCode::SUCCESS
}

/// Try to find and select a program from a command
Expand Down

0 comments on commit cad11e4

Please sign in to comment.