Skip to content

Instantly share code, notes, and snippets.

@Prototyped
Created October 15, 2023 16:31
Show Gist options
  • Select an option

  • Save Prototyped/a7be4aba88cfd9e171ff5ca3a0688817 to your computer and use it in GitHub Desktop.

Select an option

Save Prototyped/a7be4aba88cfd9e171ff5ca3a0688817 to your computer and use it in GitHub Desktop.
.profile bridge with .conf/environment.d/*.conf
for conf in "$HOME/.config/environment.d"/*.conf
do
if [ -r "$conf" ]
then
substituted="/tmp/${LOGNAME}.envs.systemd.blows.$$.txt"
envsubst < "$conf" > "$substituted"
while read -r line
do
new_cleaned_up="${line%#*}"
cleaned_up=""
while [ "$new_cleaned_up" != "$cleaned_up" ]
do
cleaned_up="$new_cleaned_up"
new_cleaned_up="${cleaned_up%%[[:space:]]}"
done
cleaned_up="$new_cleaned_up"
unset new_cleaned_up
if [ "$cleaned_up" != "${cleaned_up%%=*}" ]
then
var="${cleaned_up%%=*}"
val="${cleaned_up#*=}"
eval "${var}='${val}'"
export "$var"
unset var val
fi
unset cleaned_up
done < "$substituted"
unset line
rm -f "$substituted"
unset substituted
fi
done
unset conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment