Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 584

Shell script for copying environment variables into config.json? [duplicate]

$
0
0

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.


Viewing all articles
Browse latest Browse all 584

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>