Fix f.sh: echo -> printf when writing a taught fix to p, first change to f.sh all session -- see HF commit for full detail

This commit is contained in:
2026-08-18 03:44:34 -04:00
parent 1fc1f87be5
commit 602e2ee4bd
+12 -1
View File
@@ -25,7 +25,18 @@ f() {
printf '\n[LEARN] "%s" failed. Enter a fix (blank to give up): ' "$*" >&2 printf '\n[LEARN] "%s" failed. Enter a fix (blank to give up): ' "$*" >&2
read -r n read -r n
[ -n "$n" ] || return 1 [ -n "$n" ] || return 1
echo "$*=$n" >> p # printf, not echo: POSIX leaves it implementation-defined whether
# echo interprets backslash escapes in its argument, and dash/
# busybox ash both do by default (bash's echo doesn't, unless
# -e). A taught fix containing a literal "\n" -- e.g. any fix
# that itself uses printf '%s\n' internally, which is common and
# idiomatic -- got silently corrupted into a real embedded
# newline on write, breaking p's one-fix-per-line format the
# moment that fix was replayed. Confirmed live: identical fix
# text taught under bash was fine; the same text taught under
# `sh` (dash) truncated mid-line on replay. printf's %s never
# interprets escapes in the substituted value, under any shell.
printf '%s=%s\n' "$*" "$n" >> p
FIX="$n" FIX="$n"
done done
} }