From 2798682a1d6a0c701792ba67fd00493ccdc14171 Mon Sep 17 00:00:00 2001 From: Valerie Wolfe Date: Mon, 8 Jul 2024 13:09:51 -0400 Subject: [PATCH] env-share: added git-bash companion script --- README.md | 5 +++++ env-share/scripts/env-share.sh | 19 +++++++++++++++++++ man/env-share.1 | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 env-share/scripts/env-share.sh diff --git a/README.md b/README.md index 2e0507a..4b5f887 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,11 @@ 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 diff --git a/env-share/scripts/env-share.sh b/env-share/scripts/env-share.sh new file mode 100644 index 0000000..7746c76 --- /dev/null +++ b/env-share/scripts/env-share.sh @@ -0,0 +1,19 @@ +#!/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 + diff --git a/man/env-share.1 b/man/env-share.1 index 607b6d3..5657d8e 100644 --- a/man/env-share.1 +++ b/man/env-share.1 @@ -9,7 +9,7 @@ .Sh DESCRIPTION The .Nm -utility writes environment variables to a file to be loaded by a script in the target process. +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