File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
.github/workflows/scripts Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ rewrite_paths() {
3939 -e ' s@(/?)templates/@.specify/templates/@g'
4040}
4141
42+ escape_sed_replacement () {
43+ # Escape special characters in sed replacement text:
44+ # - & (expands to matched pattern)
45+ # - | (our delimiter)
46+ # - \ (escape character)
47+ sed ' s/[&\|\\]/\\&/g'
48+ }
49+
4250generate_commands () {
4351 local agent=$1 ext=$2 arg_format=$3 output_dir=$4 script_variant=$5
4452 mkdir -p " $output_dir "
@@ -71,11 +79,13 @@ generate_commands() {
7179 ' )
7280
7381 # Replace {SCRIPT} placeholder with the script command
74- body=$( printf ' %s\n' " $file_content " | sed " s|{SCRIPT}|${script_command} |g" )
82+ escaped_script=$( printf ' %s\n' " $script_command " | escape_sed_replacement)
83+ body=$( printf ' %s\n' " $file_content " | sed " s|{SCRIPT}|${escaped_script} |g" )
7584
7685 # Replace {AGENT_SCRIPT} placeholder with the agent script command if found
7786 if [[ -n $agent_script_command ]]; then
78- body=$( printf ' %s\n' " $body " | sed " s|{AGENT_SCRIPT}|${agent_script_command} |g" )
87+ escaped_agent=$( printf ' %s\n' " $agent_script_command " | escape_sed_replacement)
88+ body=$( printf ' %s\n' " $body " | sed " s|{AGENT_SCRIPT}|${escaped_agent} |g" )
7989 fi
8090
8191 # Remove the scripts: and agent_scripts: sections from frontmatter while preserving YAML structure
You can’t perform that action at this time.
0 commit comments