summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtools/shld.sh18
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/shld.sh b/tools/shld.sh
index a1840f2..88973ed 100755
--- a/tools/shld.sh
+++ b/tools/shld.sh
@@ -49,6 +49,15 @@ link()
printf '#!%s\n' "${interpreter}" >&3
fi
+ # Write __init() function.
+ cat >&3 <<-'EOF'
+ __init_funcs=''
+ __init()
+ {
+ __init_funcs="${__init_funcs} ${1}"
+ }
+ EOF
+
# Read input files.
for input in "${@}"; do
if ! cat "${input}" >&3; then
@@ -56,9 +65,16 @@ link()
fi
done
+ # Add call to init functions.
+ cat >&3 <<-'EOF'
+ for __func in ${__init_funcs}; do
+ ${__func}
+ done
+ EOF
+
# Add call to entry point.
if ${make_executable}; then
- printf '\n%s "${@}"\n' "${entry_point}" >&3
+ printf '%s "${@}"\n' "${entry_point}" >&3
fi
# Close output file, make it executable, and set its name.