6 function startswith() {
8 declare -l prelude="${2}"
9 declare -l line=$(head -n1 "$file")
10 if [ "$line" != "$prelude" ]; then
11 echo "$prelude" | cat - "$file" > "$file.tmp" && mv "$file.tmp" "$file"
16 declare -l base="${1}"
17 find "$base" -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do
19 declare -l file_h="${file%.qc}.qh"
20 if [[ ! -f "$file_h" ]]; then echo "#pragma once" > "$file_h"; fi
22 include=$(basename "$file")
23 include="${include%.qc}.qh"
24 include="#include \"${include}\""
25 startswith "$file" "$include"
27 find "$base" -type f -name '*.qh' -a \! -name '_mod.qh' -print0 | sort -z | while read -r -d '' file; do
29 startswith "$file" "#pragma once"