Compare commits
No commits in common. "2798682a1d6a0c701792ba67fd00493ccdc14171" and "2445530f9b847741a9b555926edcadecc29280ac" have entirely different histories.
2798682a1d
...
2445530f9b
8 changed files with 0 additions and 135 deletions
|
@ -4,11 +4,6 @@
|
|||
These are tools I use to use Windows primarily through WSL. A lot of them
|
||||
assume you have PowerShell somewhere in your `PATH` as "`pwsh`".
|
||||
|
||||
## `env-share`
|
||||
|
||||
A hacked-together utility for sending WSL variables back to Windows
|
||||
shells. The utility runs in WSL, and companion scripts run in Windows.
|
||||
|
||||
## `mkwin`
|
||||
|
||||
A Linux utility to quickly make a bash script to run a Windows executable with
|
||||
|
|
2
env-share/.gitignore
vendored
2
env-share/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
/target
|
||||
Cargo.lock
|
|
@ -1,12 +0,0 @@
|
|||
[package]
|
||||
name = "env-share"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
|
||||
[profile.release]
|
||||
opt-level = 's'
|
||||
codegen-units = 1
|
||||
debug = false
|
||||
lto = true
|
||||
panic = "abort"
|
||||
strip = "symbols"
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
# make sure the file exists
|
||||
$file = $env:ENV_SHARE_FILE
|
||||
if(-not (Test-Path $file)) {
|
||||
exit
|
||||
}
|
||||
|
||||
# insert values into env
|
||||
foreach($line in Get-Content $file) {
|
||||
$parts = $line -split ' = '
|
||||
$var = $parts[0]
|
||||
$value = $parts[1]
|
||||
Set-Item env:$var -Value $value
|
||||
}
|
||||
|
||||
# delete the file
|
||||
Remove-Item $file
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# make sure file is present
|
||||
file=$ENV_SHARE_FILE
|
||||
if [[ ! -r "$file" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# read lines and set variables
|
||||
IFS=' = '
|
||||
while read line; do
|
||||
var=${line%$IFS*}
|
||||
value=${line#*$IFS}
|
||||
export $var=$value
|
||||
done <$file
|
||||
|
||||
# delete file
|
||||
rm $file
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
use std::process::exit;
|
||||
|
||||
pub fn file_unset() {
|
||||
println!("env-share: ENV_SHARE_FILE is unset");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pub fn vars_unset() {
|
||||
println!("env-share: ENV_SHARE_VARS is unset");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
pub fn write_fail(file: &String) {
|
||||
println!("env-share: failed to write to '{file}'");
|
||||
exit(2);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
use std::{
|
||||
env,
|
||||
fs::write
|
||||
};
|
||||
|
||||
mod error;
|
||||
|
||||
fn main() {
|
||||
// try to get share file variable
|
||||
if let Ok(file) = env::var("ENV_SHARE_FILE") {
|
||||
if let Ok(var_string) = env::var("ENV_SHARE_VARS") {
|
||||
// build output
|
||||
let mut output = String::new();
|
||||
let vars = var_string.split(':');
|
||||
for var in vars {
|
||||
let value = env::var(var).unwrap_or(String::new());
|
||||
if value.is_empty() { continue; }
|
||||
|
||||
output += &format!("{var} = {value}\n");
|
||||
}
|
||||
|
||||
// write to file
|
||||
let result = write(&file, output);
|
||||
match result {
|
||||
Err(_) => error::write_fail(&file),
|
||||
_ => { }
|
||||
}
|
||||
} else { error::vars_unset(); }
|
||||
} else { error::file_unset(); }
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
.Dd $Mdocdate$
|
||||
.Dt ENV-SHARE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm env-share
|
||||
.Nd share environment variables back to Windows from WSL
|
||||
.Sh SYNOPSIS
|
||||
.Nm env-share
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility writes environment variables to a file to be loaded by a companion script in the target process.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width Ds
|
||||
.It Ev ENV_SHARE_FILE
|
||||
The file to write variables to.
|
||||
.It Ev ENV_SHARE_VARS
|
||||
A colon-separated list of variables to copy.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Bl -tag -width Ds
|
||||
.It 1
|
||||
An environment variable is unset.
|
||||
.It 2
|
||||
Failed to write to the file at
|
||||
.Ev ENV_SHARE_FILE
|
||||
.El
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
.An Valerie Wolfe Aq Mt sleeplessval@gmail.com
|
Loading…
Reference in a new issue