I have script like this
#!/bin/bash
# exit when any command fails
set -euo pipefail
api_key="${POWERDNS_API_KEY}"
dns_server_addr="127.0.0.1"
server_id="localhost"
zone_id="${K8S_FQDN_SUFFIX}."
prefix="$1"
ip="$2"
read -rd '' payload << EOF
{
"rrsets": [
{
"name": "$prefix.svc.${K8S_FQDN_SUFFIX}.",
"type": "A",
"changetype": "REPLACE",
"ttl": 10,
"records": [
{
"content": "$ip",
"disabled": false
}
]
}
]
}
EOF
curl -i -H "X-API-Key: $api_key" -X PATCH --data "$payload" \
"http://$dns_server_addr:8081/api/v1/servers/$server_id/zones/$zone_id"
It fails on read -rd '' payload
without message. If I remove set -euo pipefail
everything works fine. What I do wrong? Actually I don't even need set -euo pipefail
, just interesting why this happens.