view bin/learn_append @ 10288:2914125a0a85

<oerjan> le/rn tmp//tmp/ is a directory for files that are not worth saving in HackEgo history, but which should still survive a single command. Note that it interacts funnily with HackEgo\'s lock and re-run commit check: files can disappear if you don\'t know what you\'re doing. Basically, don\'t modify files inside and outside tmp/ in the same HackEgo command.
author HackBot
date Thu, 16 Feb 2017 17:28:09 +0000
parents c989a1669243
children 364f0d88ee3a
line wrap: on
line source

#!/bin/bash
topic="$(echo "$1" | lowercase | sed 's/^\(an\?\|the\) //;s/s\? .*//')"
stuff=$(echo "$1" | cut -d' ' -f2-)
perl -i -p -e 's/\n/ /' "wisdom/$topic"
echo "$stuff" >>"wisdom/$topic"
echo -n "Learned '$topic': "
cat "wisdom/$topic"