Created
October 15, 2023 16:31
-
-
Save Prototyped/a7be4aba88cfd9e171ff5ca3a0688817 to your computer and use it in GitHub Desktop.
.profile bridge with .conf/environment.d/*.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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