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 4274227417
commit bcd9c57691

View file

@ -254,7 +254,8 @@ cmd_render_route() {
# Strip any existing block for this app from the aggregate file. # Strip any existing block for this app from the aggregate file.
if [[ -f "${APP_ROUTE_FILE}" ]]; then 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 else
printf "" >"${tmp}" printf "" >"${tmp}"
fi fi
@ -335,7 +336,7 @@ cmd_remove() {
if [[ -f "${APP_ROUTE_FILE}" ]]; then if [[ -f "${APP_ROUTE_FILE}" ]]; then
local tmp local tmp
tmp="$(mktemp)" 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}" mv "${tmp}" "${APP_ROUTE_FILE}"
fi fi