my environment variable contained double-quotes as follows:
$echo $CONNECT_SASL_JAAS_CONFIG
org.apache.kafka.common.security.plain.PlainLoginModule required username="USER" password="XXXX/YYY";
output from "export" command:
declare -x CONNECT_SASL_JAAS_CONFIG="org.apache.kafka.common.security.plain.PlainLoginModule required username=\"USER\" password=\"XXXX/YYY\";
my template file content is as follows (props.txt):
sasl.jaas.config = JAAS_CONF
I try to replace the JAAS_CONF with the env variable using following command :
sed -e "s/JAAS_CONF/$CONNECT_SASL_JAAS_CONFIG/g;" props.txt
This gives the following error :
/tmp# sed -e "s/JAAS_CONF/$CONNECT_CONSUMER_SASL_JAAS_CONFIG/g;" props.txt sed: -e expression #1, char 168: unknown option to `s'
Any tips on how to fix this ?
UPDATE:
Note:
- "password" contains "/" character
- There is a new-line char at the end of CONNECT_CONSUMER_SASL_JAAS_CONFIG
- I need to need escape the double-doubles back again.
So finally my solution was:
export TMP_JAAS=${SASL_JAAS_CONFIG//$'\"'/'\\"'}
export PARSED_JAAS=${TMP_JAAS//$'\n'/\ }
sed -e "s|JAAS_CONF|${PARSED_JAAS//$'\n'/\ }|g" file.cong > /tmp/app.conf