summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xtwerk38
1 files changed, 38 insertions, 0 deletions
diff --git a/twerk b/twerk index 8c9f65d..2cafd18 100755 --- a/twerk +++ b/twerk
@@ -252,6 +252,7 @@ post() {
252 printf 'Twt: ' >&2 252 printf 'Twt: ' >&2
253 read -r post 253 read -r post
254 254
255 post="$(post_expand_ats "$post")"
255 256
256 if printf '%s\n' "$post" | grep -qE '^[ \t\n]$' 257 if printf '%s\n' "$post" | grep -qE '^[ \t\n]$'
257 then 258 then
@@ -264,6 +265,43 @@ post() {
264 rm "$TWERK_CACHE/$TWERK_USER" 265 rm "$TWERK_CACHE/$TWERK_USER"
265 remain 266 remain
266} 267}
268
269post_expand_ats() {
270 TWERK_POST="$TWERK_CACHE/:post:"
271 printf '%s\n' "$@" |
272 tr ' ' '\n' |
273 while read -r word; do
274 case "$word" in
275 @*)
276 url="$(grep "${word#@}" "$TWERK_FEEDS" | cut -d' ' -f1)"
277 if test -n "$url"
278 then
279 printf '@<%s %s> ' \
280 "${word#@}" "$url"
281 else
282 printf '%s ' "$word"
283 fi
284 ;;
285 *) printf '%s ' "$word";;
286 esac
287 done > "$TWERK_POST"
288 echo >> "$TWERK_POST"
289
290 if grep -q @ "$TWERK_POST"
291 then
292 cat "$TWERK_POST" >&2
293 printf '%s\n' "Correct? [Y/n] " >&2
294 read -r yn
295 case "$yn" in
296 n*|N*)
297 head -n1 "$TWERK_POST" >&2
298 post
299 ;;
300 y*|Y*|'') ;;
301 *) return 3 ;;
302 esac
303 fi
304 head -n1 "$TWERK_POST"
267} 305}
268 306
269refresh() { 307refresh() {