From fe3b85ba3d9a3c45f89e2937ea5f65d3e0b9b571 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Thu, 2 Apr 2026 17:07:21 +0200 Subject: [PATCH] add includer --- tools/includer | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 tools/includer diff --git a/tools/includer b/tools/includer new file mode 100755 index 0000000..1efbafa --- /dev/null +++ b/tools/includer @@ -0,0 +1,25 @@ +#!/bin/bash + +main() +{ + local file="$1" + local dir=$(dirname "$file") + local regex="^#include \"\(.*\)\"$" + + local include_files=$(cat "$file" \ + | grep --only-matching "$regex" \ + | sed "s/$regex/\1/") + + local include_file= + local out=$(cat $file) + for include_file in $include_files; do + local include_regex="#include \"$include_file\"" + out=$(echo "$out" \ + | sed "/$include_regex/r $dir/$include_file" \ + | sed "/$include_regex/d") + done + + echo "$out" +} + +main $* \ No newline at end of file -- 2.47.3