commit 71c9f844e6456d1c07e0cd1ebd49bdb0260b4879
parent f5c96d71fac2302a810a4b8b8179af1dcf0ca595
Author: Riaz <riaz@riazj.com>
Date: Tue, 9 Sep 2025 11:50:22 -0700
bin/todo: Use grep instead of sed to treat text as is
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/.local/bin/todo b/.local/bin/todo
@@ -1,12 +1,13 @@
-#!/bin/sh -e
+#!/bin/sh
TODO="$HOME/todo"
height="$(wc -l "$TODO")"
height="${height% *}"
while sel="$(dmenu -i -l "$height" < "$TODO")"; do
- if grep -q "^$sel$" "$TODO"; then
- sed -i "/^$sel$/d" "$TODO"
+ if grep -Fqx "$sel" "$TODO"; then
+ grep -vFx "$sel" "$TODO" > "$TODO.tmp"
+ mv "$TODO.tmp" "$TODO"
height=$((height-1))
else
echo "$sel" >> "$TODO"