File tree Expand file tree Collapse file tree 2 files changed +50
-2
lines changed
Tools/configure/transpiler Expand file tree Collapse file tree 2 files changed +50
-2
lines changed Original file line number Diff line number Diff line change 3535# This is a POSIX shell wrapper around an embedded AWK program.
3636# Run: /bin/sh configure [options]
3737
38+ # _find_awk — pick a working AWK that is not gawk.
39+ # gawk 5.2.x (Ubuntu 24.04) has a crash bug ("double free or corruption")
40+ # triggered by heavy system() usage in large scripts. mawk and one-true-awk
41+ # (nawk / BWK awk) are unaffected and faster, so prefer them.
42+ _find_awk() {
43+ for _c in mawk nawk awk; do
44+ # Locate $_c in PATH without relying on "command -v".
45+ IFS=:
46+ for _d in $PATH; do
47+ if [ -x "${_d}/${_c}" ]; then
48+ # Reject gawk — it sometimes masquerades as "awk" or "nawk".
49+ case $("${_d}/${_c}" --version < /dev/null 2>&1) in
50+ *"GNU Awk"*) ;;
51+ *) echo "${_d}/${_c}"; return 0 ;;
52+ esac
53+ fi
54+ done
55+ unset IFS
56+ done
57+ # Last resort: bare "awk" (may be gawk, but better than nothing).
58+ echo awk
59+ }
60+ _awk=$(_find_awk)
61+
3862_tmpf=$(mktemp "${TMPDIR:-/tmp}/configure.XXXXXXXXXX") || exit 1
3963trap 'rm -f "$_tmpf"' EXIT
4064sed '1,/^#---AWK-START---$/d' "$0" > "$_tmpf"
41- exec awk -f "$_tmpf" -- "$@"
65+ exec "$_awk" -f "$_tmpf" -- "$@"
4266#---AWK-START---
4367"""
4468
Original file line number Diff line number Diff line change 33# This is a POSIX shell wrapper around an embedded AWK program.
44# Run: /bin/sh configure [options]
55
6+ # _find_awk — pick a working AWK that is not gawk.
7+ # gawk 5.2.x (Ubuntu 24.04) has a crash bug ("double free or corruption")
8+ # triggered by heavy system() usage in large scripts. mawk and one-true-awk
9+ # (nawk / BWK awk) are unaffected and faster, so prefer them.
10+ _find_awk() {
11+ for _c in mawk nawk awk; do
12+ # Locate $_c in PATH without relying on "command -v".
13+ IFS=:
14+ for _d in $PATH; do
15+ if [ -x "${_d}/${_c}" ]; then
16+ # Reject gawk — it sometimes masquerades as "awk" or "nawk".
17+ case $("${_d}/${_c}" --version < /dev/null 2>&1) in
18+ *"GNU Awk"*) ;;
19+ *) echo "${_d}/${_c}"; return 0 ;;
20+ esac
21+ fi
22+ done
23+ unset IFS
24+ done
25+ # Last resort: bare "awk" (may be gawk, but better than nothing).
26+ echo awk
27+ }
28+ _awk=$(_find_awk)
29+
630_tmpf=$(mktemp "${TMPDIR:-/tmp}/configure.XXXXXXXXXX") || exit 1
731trap 'rm -f "$_tmpf"' EXIT
832sed '1,/^#---AWK-START---$/d' "$0" > "$_tmpf"
9- exec awk -f "$_tmpf" -- "$@"
33+ exec "$_awk" -f "$_tmpf" -- "$@"
1034#---AWK-START---
1135# === pyconf.awk runtime ===
1236# pyconf.awk — AWK runtime library for the configure transpiler.
You can’t perform that action at this time.
0 commit comments