summaryrefslogtreecommitdiffstats
path: root/Reaktor/reaktor/commands/tell-on_join
blob: 2dbff41a41167b7f26436b07462b864bef2ae0b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /bin/sh
set -euf

# require flock from util-linux
if test "${FLOCK-}" != "$state_file"; then
  exec env FLOCK="$state_file" flock "$state_file" "$0" "$@"
fi

to="$_from"

# print messages
sed -n '/^'"$to"' /{
  s/^\([^ ]\+\) \([^ ]\+\) <\([^>]\+\)> \(.*\)/\1: \4 2-- \2, \3/p
}' "$state_file"

# delete messages
sed -i '/^'"$to"' /{
  d
}' "$state_file"