The script ran its code at the top level. prompts/CODE_STYLEGUIDE.md says to put all shell code in functions, with a main called at the bottom, and every other script in script/ does. The code now sits in main(), and the last line calls it. Model: opus-5-5
This commit is contained in:
1 parent
29496c2586
commit
6378311ac5
1 file changed
+7
-3
@@ -19,6 +19,7 @@ die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
[ ! -e prompts/REPO_POLICIES.md ] ||
|
||||
die "this is the prompts repo, where these files come from"
|
||||
@@ -33,9 +34,9 @@ done
|
||||
[ -z "$(git status --porcelain -- $paths)" ] ||
|
||||
die "commit or discard your changes to these files first:$paths"
|
||||
|
||||
# Every file is fetched before any is replaced. The temporary directory
|
||||
# is inside the repo so that mv renames: the running script is replaced
|
||||
# by a new file, never rewritten in place.
|
||||
# Every file is fetched before any is replaced. The temporary
|
||||
# directory is inside the repo so that mv renames: the running script
|
||||
# is replaced by a new file, never rewritten in place.
|
||||
tmp="$(mktemp -d "$ROOT/.update-policy.XXXXXX")"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
for entry in $FILES; do
|
||||
@@ -57,3 +58,6 @@ else
|
||||
git commit -q -m "Update policy files from prompts" -- $paths
|
||||
echo "update-policy: committed; review it, then push"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in new issue
Block a user