diff options
author | P. J. McDermott <pj@pehjota.net> | 2015-10-27 16:11:59 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2015-10-27 16:11:59 (EDT) |
commit | 38948ca18b00e121ed08a4d7a857cbb2a1b72db7 (patch) | |
tree | 043fb7b8ff6642b35d9178f34b9507fe881414a0 | |
parent | 5e9ec24c72142e2fe9ba10ab96111b9fbfc0b3c1 (diff) | |
download | firman.sh-38948ca18b00e121ed08a4d7a857cbb2a1b72db7.zip firman.sh-38948ca18b00e121ed08a4d7a857cbb2a1b72db7.tar.gz firman.sh-38948ca18b00e121ed08a4d7a857cbb2a1b72db7.tar.bz2 |
tools/shld.sh: Add support for init functions
-rwxr-xr-x | tools/shld.sh | 18 |
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. |