diff --git a/skills/ingest/scripts/run-ingest.sh b/skills/ingest/scripts/run-ingest.sh index 4ae9c97..032761c 100644 --- a/skills/ingest/scripts/run-ingest.sh +++ b/skills/ingest/scripts/run-ingest.sh @@ -36,7 +36,7 @@ contradictions="$(jq -r '.contradictions // "None"' "$manifest")" [[ -n "$raw_source" && "$raw_source" != "null" ]] || fail "manifest" "raw_source missing" -slug="$(bash "${SCRIPTS}/slug.sh" "$raw_source")" +slug="$(bash "${SCRIPTS}/slug.sh" "$raw_source")" || fail "slug" "empty or invalid slug for ${raw_source}" # --- collect touched paths --- mapfile -t created_paths < <(jq -r '.pages[] | select(.status=="created") | .path' "$manifest") diff --git a/skills/ingest/scripts/slug.sh b/skills/ingest/scripts/slug.sh index a5711ac..2f7fdc5 100644 --- a/skills/ingest/scripts/slug.sh +++ b/skills/ingest/scripts/slug.sh @@ -13,6 +13,11 @@ input="${1:?usage: slug.sh }" base="${input##*/}" base="${base%.*}" -printf '%s\n' "$base" \ +slug="$(printf '%s\n' "$base" \ | tr '[:upper:]' '[:lower:]' \ - | sed -E 's/[^a-z0-9]+/-/g; s/-{2,}/-/g; s/^-+//; s/-+$//' + | sed -E 's/[^a-z0-9]+/-/g; s/-{2,}/-/g; s/^-+//; s/-+$//')" + +# An all-symbols input (e.g. "!!!.md") collapses to "" — refuse rather than emit a +# broken/empty slug that would produce an invalid branch name downstream. +[[ -n "$slug" ]] || { echo "slug: empty result for input '${input}'" >&2; exit 1; } +printf '%s\n' "$slug"