dotfiles

:)
git clone https://git.sr.ht/~ashymad/dotfiles
Log | Files | Refs | Submodules | LICENSE

withenv (320B)


      1 #!/bin/sh
      2 
      3 if [ "$1" = "--export" ]; then
      4     awk '{print "export \"" $0 "\""}' "$2"
      5     exit 0
      6 fi
      7 
      8 ENVFILE="$1"
      9 shift
     10 fifo="$(mktemp -d)/fifo"
     11 mkfifo "$fifo"
     12 (
     13     envsubst < "$ENVFILE" | tr '\n' '\0'
     14     [ "$#" -gt 0 ] && printf "%s\0" "$@"
     15     rm -rf "$(dirname "$fifo")"
     16 ) >> "$fifo" &
     17 
     18 exec xargs -0 -a "$fifo" env