Skip to content
Snippets Groups Projects
Unverified Commit 77c867ba authored by Liam Aharon's avatar Liam Aharon Committed by GitHub
Browse files

fix simple analytics injection script (#1501)

When `process_file` is run by `xargs`, it is executed inside a new shell
without access to variables defined outside of its scope.

This resulted in `script_content` being an empty string.

By exporting `script_content` prior to running `xargs` it is available
inside the new shells.
parent c879d1d5
Branches
No related merge requests found
Pipeline #389172 passed with stages
in 46 minutes and 38 seconds
......@@ -111,6 +111,9 @@ build-rustdoc:
sed -i "s|</head>|$script_content</head>|" "$file"
}
export -f process_file
# xargs runs process_file in seperate shells without access to outer variables.
# to make script_content available inside process_file, export it as an env var here.
export script_content
# Modify .html files in parallel using xargs, otherwise it can take a long time.
find "$path" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'process_file "$@"' _ {}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment