Created
March 23, 2020 14:50
-
-
Save nomyfan/6669ab41aea31e09735feadfb92b6336 to your computer and use it in GitHub Desktop.
WSL Broker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::Write; | |
use std::path::Path; | |
use std::process::Command; | |
fn main() { | |
let args: std::vec::Vec<String> = std::env::args().collect(); | |
let bin_name = Path::new(&args[0]).file_stem().unwrap(); | |
let mut cmd = Command::new("wsl"); | |
cmd.arg("--").arg(bin_name); | |
if args.len() > 1 { | |
cmd.args(&args[1..]); | |
} | |
let output = cmd.output().expect("failed to execute command in WSL"); | |
std::io::stderr().write_all(&output.stderr).unwrap(); | |
std::io::stdout().write_all(&output.stdout).unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment