From 38948ca18b00e121ed08a4d7a857cbb2a1b72db7 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 27 Oct 2015 16:11:59 -0400 Subject: tools/shld.sh: Add support for init functions --- (limited to 'tools/shld.sh') 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. -- cgit v0.9.1