I am not able to debug why it is returning
nullvalue. Can some-one please help into this.
Code -
getJSONParamater() {
echo "Before : $1 $2 $3"
eval "$3=$(cat $1 | jq '."$2"')"
echo "After : $1 $2 $3"
}
return_value='default'
getJSONParamater etl-without-transformation.json success_email return_value
echo $return_value
cat ... | jq ...command is returning nullset -xat the top. Then it will display each line as it executes it, so you can see what's going wrong.declareinstead ofeval(although there are even better alternatives) to protect against (some) unintended code evaluation. An extreme example isgetJSONParameter f.json value ":; echo hi; name", which would echo "hi" before settingnameequal to the result of the command.