Simulated shell
p (learned fixes)
// empty — nothing learned yet
A shell function that learns from its own failures — run a command, teach it a fix when it fails, and it never fails that way again.
This is a live simulation of f() running entirely in your browser. Try a command below.
f() {
FIX=""
if [ -f p ]; then
while IFS= read -r line; do
case "$line" in
"$*="*) FIX="${line#"$*="}" ;;
esac
done < p
fi
until { eval "$FIX" 2>/dev/null; "$@"; }; do
printf '\n[LEARN] "%s" failed. Enter a fix (blank to give up): ' "$*" >&2
read -r n
[ -n "$n" ] || return 1
echo "$*=$n" >> p
FIX="$n"
done
}