Skip to content

fix(mode): update .env atomically via mv -f in mode-switch.sh - #2767

Open
vaibhavsrv wants to merge 1 commit into
Osmantic:mainfrom
vaibhavsrv:fix/mode-switch-atomic-env-update
Open

fix(mode): update .env atomically via mv -f in mode-switch.sh#2767
vaibhavsrv wants to merge 1 commit into
Osmantic:mainfrom
vaibhavsrv:fix/mode-switch-atomic-env-update

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Problem

In ods/scripts/mode-switch.sh, env_set() updates .env values by redirecting awk output to "${ENV_FILE}.tmp" and overwriting $ENV_FILE via cat "${ENV_FILE}.tmp" > "$ENV_FILE". Overwriting directly via redirection is non-atomic and risks zero-byte truncation if process execution is interrupted.

Fix

Replace cat ... > ... && rm -f ... with a direct atomic mv -f "${ENV_FILE}.tmp" "$ENV_FILE" operation in mode-switch.sh.

Verification

Ran bash -n ods/scripts/mode-switch.sh (passed cleanly). git diff --check passed cleanly.

@vaibhavsrv
vaibhavsrv force-pushed the fix/mode-switch-atomic-env-update branch from 0e93c59 to ffe899d Compare August 30, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant