# SPDX-License-Identifier: BSD-2-Clause BEGIN { AWK = "/usr/bin/original-awk" awk_switches = " -f" trivial_program = " 'BEGIN { print \"hi\" }' " no_output = " >/dev/null 2>/dev/null" if (0 != system(awk_executable trivial_program no_output)) { AWK = "/usr/bin/awk" # now, what do we need to hand it to get no bells and # whistles? with GNU awk, we need -c, but One True Awk does # not recognize this switch, and will exit with an error when # it is provided. if(0 == system(AWK " -c " trivial_program no_output)) { awk_switches = " -cf" } else { # leave awk_switches alone } } } /^@target/ { next } /^@shebang/ { print "#!" AWK awk_switches next } /^@include-commented/ { fn = $2 while((AWK " -f tmpl.awk " fn | getline) > 0) print "# " $0 next } /^@include/ { fn = $2 print "# --- " fn while((AWK " -f tmpl.awk " fn | getline) > 0) print print "# --- " fn " ends" print "" next } { print }