view bin/slashlearn @ 9879:f931749ff54e

<oerjan> sled bin/slashlearn//2s,exit 1,{ echo \'All le//rn variants now use two slashes in the format.\' >\\&2 ; exit 1 },
author HackBot
date Tue, 06 Dec 2016 03:09:19 +0000
parents 3238443d09f6
children 68aaf05e3aec
line wrap: on
line source

sep="//"
[[ "$1" == ?*"$sep"* ]] || { echo 'All le//rn variants now use two slashes in the format.' >&2 ; exit 1 }
key="$(echo "${1%%$sep*}" | lowercase)"
value="${1#*$sep}"
[ -e "wisdom/$key" ] && verb="Relearned" || verb="Learned"
echo "$value" > "$(echo-p "wisdom/$key")" && echo -n "$verb '$key': $(echo "$value" | sed 's.^[ ].0,04&.')"