Refactor route removal in cmd_render_route and cmd_remove to use sed for block deletion

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Jakub Dorfman 2026-04-26 23:23:26 +02:00
parent b8969bc6f7
commit 7072fc9a37

View file

@ -254,7 +254,8 @@ cmd_render_route() {
# Strip any existing block for this app from the aggregate file.
if [[ -f "${APP_ROUTE_FILE}" ]]; then
grep -v "^# route:${name}:" "${APP_ROUTE_FILE}" >"${tmp}" || true
# Use sed to remove the block between # route:name:start and # route:name:end
sed "/^# route:${name}:start$/,/^# route:${name}:end$/d" "${APP_ROUTE_FILE}" >"${tmp}" || true
else
printf "" >"${tmp}"
fi
@ -335,7 +336,7 @@ cmd_remove() {
if [[ -f "${APP_ROUTE_FILE}" ]]; then
local tmp
tmp="$(mktemp)"
grep -v "^# route:${name}:" "${APP_ROUTE_FILE}" >"${tmp}"
sed "/^# route:${name}:start$/,/^# route:${name}:end$/d" "${APP_ROUTE_FILE}" >"${tmp}" || true
mv "${tmp}" "${APP_ROUTE_FILE}"
fi