34 lines
1.4 KiB
Bash
34 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Reapply the scheduler tool wrappers after `bash -lc` processes login files.
|
|
if [[ -n "${FREECAD_SCHEDULER_BIN:-}" ]]; then
|
|
export PATH="${FREECAD_SCHEDULER_BIN}:${PATH}"
|
|
fi
|
|
|
|
# Codex command tools may start a login shell from the outer workspace even
|
|
# when the parent process was launched with `-C`. Normalize every scheduled
|
|
# shell to the explicit project root; a command can still `cd` elsewhere when
|
|
# its current module genuinely requires it.
|
|
if [[ -n "${FREECAD_SCHEDULER_ROOT:-}" && -d "${FREECAD_SCHEDULER_ROOT}" ]]; then
|
|
cd "${FREECAD_SCHEDULER_ROOT}"
|
|
fi
|
|
|
|
# The event loop sets this marker after the current turn's read budget.
|
|
# rg already observes it; bounded sed excerpts must not bypass the same budget.
|
|
sed() {
|
|
if [[ -n "${FREECAD_SOURCE_BUDGET_MARKER:-}" && -f "$FREECAD_SOURCE_BUDGET_MARKER" ]]; then
|
|
local scheduler_sed_argument
|
|
local scheduler_sed_in_place=false
|
|
for scheduler_sed_argument in "$@"; do
|
|
case "$scheduler_sed_argument" in
|
|
-i*|--in-place|--in-place=*) scheduler_sed_in_place=true ;;
|
|
esac
|
|
done
|
|
if [[ "$scheduler_sed_in_place" == false ]]; then
|
|
echo "SCHEDULER_SOURCE_BUDGET_REACHED: sed was not executed. Reuse retained excerpts; for a missing packet-file anchor use python3 tools/read_implementation_source.py FILE --start LINE --lines 60 --reason 'missing anchor'." >&2
|
|
return 64
|
|
fi
|
|
fi
|
|
command sed "$@"
|
|
}
|