Current section

Files

Jump to
gpb build prepend_edoc_autogenerated
Raw

build/prepend_edoc_autogenerated

#! /bin/sh
f="$1"
orig="${2:-$f}"
if (head -n 1 "$f" | grep -q '@doc automatically generated scanner')
then
# already prepended
exit 0
fi
cleanup () {
rm -f "$f".tmp
}
trap 'ec=$?; cleanup; exit $ec' EXIT QUIT INT TERM
set -e
cat > "$f".tmp <<EOF
%% @doc automatically generated scanner
%% @private
%% @end
-file("$orig", 0).
EOF
cat "$f" >> "$f".tmp
touch -r "$f" "$f".tmp
mv "$f.tmp" "$f"