hug: initial implementation

This commit is contained in:
Valerie Wolfe 2024-07-15 13:21:43 -04:00
parent bf3e86a5df
commit 43d5cbd4aa
4 changed files with 50 additions and 0 deletions

View file

@ -13,6 +13,10 @@ Gets Windows environment variables from DOS.
A hacked-together utility for sending WSL variables back to Windows A hacked-together utility for sending WSL variables back to Windows
shells. The utility runs in WSL, and companion scripts run in Windows. shells. The utility runs in WSL, and companion scripts run in Windows.
## `hug`
A wrapper for turning binary-output text into normal text.
## `mkwin` ## `mkwin`
A Linux utility to quickly make a bash script to run a Windows executable with A Linux utility to quickly make a bash script to run a Windows executable with

2
hug/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/target
Cargo.lock

13
hug/Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "hug"
version = "0.0.1"
edition = "2021"
[profile.release]
opt-level = 's'
codegen-units = 1
debug = false
lto = true
panic = "abort"
strip = "symbols"

31
hug/src/main.rs Normal file
View file

@ -0,0 +1,31 @@
use std::{
env, net::ToSocketAddrs, process::{ Command, Stdio }
};
fn main() {
let mut args: Vec<String> = env::args().collect();
args.remove(0);
let target = args.remove(0);
let command = Command::new(target)
.args(args)
.stderr(Stdio::inherit())
.output();
if let Ok(output) = command {
let mut line = String::new();
for byte in output.stdout {
match char::from_u32(byte.into()) {
Some('\n') => {
println!("{line}");
line = String::new();
},
Some('\0') |
None => continue,
Some(c) => line.push(c),
}
}
}
}