Merge branch 'hug'
This commit is contained in:
commit
2d88ac6f45
7 changed files with 87 additions and 0 deletions
|
@ -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 barebones command 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
2
hug/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/target
|
||||||
|
Cargo.lock
|
13
hug/Cargo.toml
Normal file
13
hug/Cargo.toml
Normal 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"
|
||||||
|
|
10
hug/justfile
Normal file
10
hug/justfile
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
alias b := build
|
||||||
|
alias i := install
|
||||||
|
|
||||||
|
build:
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
install DIR: build
|
||||||
|
cp ./target/release/hug "{{DIR}}/hug"
|
||||||
|
|
32
hug/src/main.rs
Normal file
32
hug/src/main.rs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
use std::{
|
||||||
|
env,
|
||||||
|
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),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
1
justfile
1
justfile
|
@ -11,6 +11,7 @@ install TARGET='all' DIR="~/.bin/":
|
||||||
just install scripts {{DIR}}
|
just install scripts {{DIR}}
|
||||||
just install dos-var {{DIR}}
|
just install dos-var {{DIR}}
|
||||||
just install env-share {{DIR}}
|
just install env-share {{DIR}}
|
||||||
|
just install hug {{DIR}}
|
||||||
just install mkwin {{DIR}}
|
just install mkwin {{DIR}}
|
||||||
just install path-convert {{DIR}}
|
just install path-convert {{DIR}}
|
||||||
just install qdls {{DIR}}
|
just install qdls {{DIR}}
|
||||||
|
|
25
man/hug.1
Normal file
25
man/hug.1
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
.Dd $Mdocdate$
|
||||||
|
.Dt HUG 1
|
||||||
|
.Os WSL
|
||||||
|
.Sh NAME
|
||||||
|
.Nm hug
|
||||||
|
.Nd wraps processes and converts binary output to text
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Ar target
|
||||||
|
.Op Ar args...
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility runs a process and emits bytes from standard output to text.
|
||||||
|
.Sh EXAMPLES
|
||||||
|
WSL's help text is output as binary content, preventing piping to utilities like
|
||||||
|
.Xr less 1
|
||||||
|
or
|
||||||
|
.Xr bat 1 :
|
||||||
|
.Pp
|
||||||
|
.Dl $ hug wsl --help | less
|
||||||
|
.Pp
|
||||||
|
.Sh Authors
|
||||||
|
.An -nosplit
|
||||||
|
.An Valerie Wolfe Aq Mt sleeplessval@gmail.com
|
Loading…
Reference in a new issue