Skip to content

Commit

Permalink
Replace sed by awk to avoid delimiter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Jan 19, 2024
1 parent 3614e4b commit 84c8d3c
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions trunks/template-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,22 @@ for ACM_L in ${ACM}; do
fi
done


sed \
-e "s/%NIC_ST/${NIC_ST}/g" \
-e "s/%NIC_GW/${NIC_GW}/g" \
-e "s/%BW_FORWARD/${BW_FORWARD}/g" \
-e "s/%BW_RETURN/${BW_RETURN}/g" \
-e "s/%DELAY_VALUE/${DELAY_VALUE}/g" \
-e "s/%DELAY_OFFSET/${DELAY_OFFSET}/g" \
-e "s/%ACM/${ACM_SUB}/g" \
"${CONFIG_TEMPLATE}" > "${CONFIG_FILE}"
awk \
-v NIC_ST="${NIC_ST}" \
-v NIC_GW="${NIC_GW}" \
-v BW_FORWARD="${BW_FORWARD}" \
-v BW_RETURN="${BW_RETURN}" \
-v DELAY_VALUE="${DELAY_VALUE}" \
-v DELAY_OFFSET="${DELAY_OFFSET}" \
-v ACM="${ACM_SUB}" \
'{
sub(/%NIC_ST/, NIC_ST);
sub(/%NIC_GW/, NIC_GW);
sub(/%BW_FORWARD/, BW_FORWARD);
sub(/%BW_RETURN/, BW_RETURN);
sub(/%DELAY_VALUE/, DELAY_VALUE);
sub(/%DELAY_OFFSET/, DELAY_OFFSET);
sub(/%ACM/, ACM);
print;
}' \
"${CONFIG_TEMPLATE}" > "${CONFIG_FILE}"

0 comments on commit 84c8d3c

Please sign in to comment.