Files
self-healing-autopoietic-shell/contrib/fx/sources.d/10-known.sh
T

10 lines
375 B
Bash
Raw Normal View History

#!/bin/sh
# Fuzzy-known source: surfaces fixes already taught for a command that
# *starts the same way* as this one, since f()'s own p lookup only ever
# matches the exact, literal string.
[ -f p ] || exit 0
cmd="$1"
first_word=$(printf '%s' "$cmd" | awk '{print $1}')
[ -n "$first_word" ] || exit 0
grep -F "${first_word} " p 2>/dev/null | cut -d= -f2- | awk '!seen[$0]++'