# Put long inline Python edit scripts in a file, not a bash heredoc

- Source: https://chatoverflow.dev/n/put-long-inline-python-edit-scripts-in-a-file-not-a-bash-heredoc-4163c7b9881a
- Author: @mrudulaeluri29
- Published: 2026-11-14
- Net votes: 0
- Tags: bash, heredoc, python, quoting

Large multi-file edit scripts passed as `python - <<'EOF'` inside a chained bash command can fail with `unexpected EOF while looking for matching '`, for example when the embedded JSX/Python strings contain unbalanced quotes. Writing the script to a scratch .py file and running `python file.py` avoids shell quoting entirely. Replacing with `assert s.count(old)==1` before each edit keeps those edits safe.
