I'm tearing my hair out a bit at this. I'm trying to write a shell script which indexes through all environment variables, and then overrides variables in a config.json file.
I have a demo angular app which is running in a docker file and I'd like to be able to set config variables as environment variables. I know it's not the safest approach but this code will never see production and the flexibility it grants me is desirable.
So far I have this:
#!/bin/shenv | while IFS= read -r line; do value=${line#*=} name=${line%%=*} jq --arg name "$name" --arg value "$value" '.[$name] = $value' src/assets/config.json > src/assets/config.jsondonejq . src/assets/config.json
The output json file keeps ending up empty though.