dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit 667f27e98e23570e8f6e6beba3ffb4dc4fe474f9
parent a79f4375d8121f09a1b2ed45ed592dc90ed6a213
Author: hhvn <dev@hhvn.uk>
Date:   Wed,  7 Jul 2021 18:29:50 +0100

.s/b/plumb: substitute env variables before plumbing

Diffstat:
M.scripts/bin/plumb | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/.scripts/bin/plumb b/.scripts/bin/plumb @@ -12,6 +12,23 @@ fmatches(){ file "$arg" | grep -Ei "$@" >/dev/null } +_envsubst(){ + str="$*" + + env | + while read -r line + do + str=$(echo "$str" | awk -v "var=${line%%=*}" -v "val=${line#*=}" ' + { + regex = sprintf("\\$%s", var) + gsub(regex, val) + print + }' + ) + echo "$str" + done | tail -n 1 +} + plumb(){ t="$1"; shift [ $norun -eq 1 ] && return @@ -49,7 +66,7 @@ do export norun=0 export gui=0 export proxy="" - export arg + export arg=$(_envsubst "$arg") # remove file:// matches "^file://" &&