I wanted to create a web assembly program that would enable me to execute bash commands and get output without contacting a server.
I created some rust code and did a wasm-pack compiling but it gives this error
RuntimeError: unreachable executed
My code
use std::process::Output;
use wasm_bindgen::prelude::*;
use std::process::Command;
#[wasm_bindgen]
pub fn exec(code:&str)->Vec<u8>{
let output = if cfg!(target_os = "windows") {
Command::new("cmd")
.args(["/C", code])
.output()
.expect("failed to execute process")
} else {
Command::new("sh")
.arg("-c")
.arg(code)
.output()
.expect("failed to execute process")
};
output.stdout
}
^^lib.rs (used wasm-pack)
RuntimeError: unreachable executed