Fix real hardware/busybox breakage: dead compgen dependency, unreliable sourced-path detection, and fork-heavy pipelines in fx sources; verified against busybox ash+awk directly

This commit is contained in:
2026-08-17 23:19:07 -04:00
parent b4d619de8a
commit df3c328424
5 changed files with 51 additions and 14 deletions
+6 -1
View File
@@ -12,6 +12,11 @@
# correctly across branches/arguments in practice. One taught fix this
# way covers every future self-diagnosing failure from that program, not
# just the one instance that happened to trigger the teaching prompt.
#
# The emitted function runs on every future call to that program for
# the rest of the session, so its own internal extraction is one awk
# pass, not a grep|sed|tail chain -- three fewer forks on every failure
# it ever handles, not just this first one.
cmd="$1"
prog=$(printf '%s' "$cmd" | awk '{print $1}')
[ -n "$prog" ] || exit 0
@@ -19,5 +24,5 @@ prog=$(printf '%s' "$cmd" | awk '{print $1}')
printf '%s\n' "$FX_OUTPUT" | grep -qE "^[[:space:]]*${prog}[[:space:]]" || exit 0
cat <<FIX
${prog}(){ out=\$(command ${prog} "\$@" 2>&1); ec=\$?; if [ \$ec -ne 0 ]; then sug=\$(printf '%s\\n' "\$out" | grep -E "^[[:space:]]*${prog}[[:space:]]" | sed 's/^[[:space:]]*//' | tail -1); if [ -n "\$sug" ]; then eval "command \$sug"; return \$?; fi; fi; printf '%s\\n' "\$out"; return \$ec; }
${prog}(){ out=\$(command ${prog} "\$@" 2>&1); ec=\$?; if [ \$ec -ne 0 ]; then sug=\$(printf '%s\\n' "\$out" | awk '/^[ \\t]*${prog}[ \\t]/{sub(/^[ \\t]*/,""); s=\$0} END{print s}'); if [ -n "\$sug" ]; then eval "command \$sug"; return \$?; fi; fi; printf '%s\\n' "\$out"; return \$ec; }
FIX