27 lines
589 B
Bash
27 lines
589 B
Bash
|
#!/bin/bash
|
||
|
LANG=C
|
||
|
# Define the file path
|
||
|
tmpl_file="./src/http_static.cpp.tmpl";
|
||
|
out_file="./src/http_static.cpp";
|
||
|
static_dir="./src/static/";
|
||
|
echo pwd;
|
||
|
echo whoami;
|
||
|
|
||
|
# Define the body variable with multiline content
|
||
|
body=$(cat "$tmpl_file")
|
||
|
|
||
|
# Iterate over the array
|
||
|
while IFS= read -r tmpl_import; do
|
||
|
echo "Found expression: $tmpl_import"
|
||
|
|
||
|
tmpl_filename="${tmpl_import:1:-1}"
|
||
|
template=$(cat "${static_dir}${tmpl_filename}")
|
||
|
|
||
|
body="${body//"$tmpl_import"/"$template"}"
|
||
|
|
||
|
# Print or save the output
|
||
|
done < <(grep -o "%[^%]*%" <<< "$body")
|
||
|
|
||
|
echo "$body" > "$out_file"
|
||
|
b
|