commit cd1e924602031edb7a1fe53f770074f4d13db2d2 from: Paul W. Rankin date: Thu Aug 04 11:59:20 2022 UTC Optionally append deleted todo to done file commit - 94b5d49cdae1aec46d7673d2ce638007186b65b0 commit + cd1e924602031edb7a1fe53f770074f4d13db2d2 blob - e387abcacc7073b0cf04ac443f7654d1fdead358 blob + eb8a2ed2ba6129cff12529039c71f84e11d542d3 --- todo.sh +++ todo.sh @@ -18,11 +18,15 @@ usage() { echo " $program [-d LINENUM] [-e] [-Ss QUERY]" } -# t_done(int) +# t_done(linenum, done) t_done() { - int=$1 + [ -f "$todo_file" ] || fail "File not found" + linenum=$1; done=$2 tmpfile=$(mktemp) - sed -n "${int}!p" "$todo_file" > "$tmpfile" + if [ "$done" -eq 1 ]; then + sed -n "${linenum}p" "$todo_file" >> "$done_file" + fi + sed "${linenum}d" "$todo_file" > "$tmpfile" mv "$todo_file" "${todo_file}~" mv "$tmpfile" "$todo_file" }