Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ replace_placeholder() {
}

# Replace in all text files
export TEST_REPO_NAME TEST_OWNER TEST_FORGE TEST_PROJECT_NAME \
TEST_DESCRIPTION TEST_PRIMARY_LANGUAGE TEST_AUTHOR TEST_AUTHOR_EMAIL
find "$TEST_REPO_PATH" -type f \
\( -name "*.md" -o -name "*.adoc" -o -name "*.a2ml" -o -name "*.zig" -o -name "*.idr" \
-o -name "Justfile" -o -name "Containerfile" -o -name "*.yml" -o -name "*.yaml" \
Expand All @@ -137,7 +139,7 @@ find "$TEST_REPO_PATH" -type f \
sed -i "s|$placeholder|$value|g" "$file"
fi
done
' _ "$file"
' _ {} \;
Comment on lines 139 to +142

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

The find syntax is now valid, but the subshell logic (lines 137-140) remains broken for several reasons:

  1. Variable Scoping: Because the sh -c command is wrapped in single quotes, $placeholder and $value are not expanded by the parent shell and will be empty in the subshell.
  2. Path Mapping: The path passed via {} becomes $1 in the subshell, but the script attempts to use $file, which is undefined.
  3. Sed Portability & Safety: The sed -i command is not portable to macOS/BSD (which requires sed -i '') and will fail if $value contains delimiters like | or the special character &.

Recommendation: Refactor the command to pass variables as positional arguments:
find ... -exec sh -c 'p="$1"; v="$2"; shift 2; for f in "$@"; do sed -i "s|$p|$v|g" "$f"; done' _ "$placeholder" "$value" {} +


log_pass "All placeholder tokens replaced"

Expand Down
Loading