Aliases usually do not work in noninteractive scripts, just terminal sessions. You could turn it on, but then you'd want to be really really careful what other aliases you might have loaded from /etc/profile without realizing it.
For situations like this, I usually see a variable used, like $NAWK .
This also prevents the sort of recursions you've fought when using functions for this.
Make own rc-file if not like add this to default rc-file:
$HOME/.xxrc file:
alias nawk='echo No nawk'
for awk in /usr/bin/gawk /usr/local/bin/gawk /usr/bin/nawk /usr/bin/awk
do
[ -x "$awk" ] && alias nawk="$awk" && break
done
# test echo - you will see this test msg everytime when you start shell
echo "Myawk:$awk" >&2
Example add line to the $HOME/.bashrc:
[ -f $HOME/.xxrc ] && . $HOME/.xxrc
If you are ksh user then add same line to the $HOME/.kshrc or setup ENV
ENV=$HOME/.xxrc
export ENV
After those rc setup, always when you execute bash or ksh, shell will source .xxrc.
I'm sure that bash has also same method as ksh has ENV variable method to setup rc-file, but I didn't check it.