2018-12-21 13:46:10 -06:00
|
|
|
#!/bin/bash
|
2018-12-21 15:26:17 -06:00
|
|
|
cowsaidfile="$(mktemp)"
|
|
|
|
cowsay "E T E R N A L" > "$cowsaidfile"
|
2018-12-21 13:46:10 -06:00
|
|
|
trap_exit() {
|
2018-12-21 15:26:17 -06:00
|
|
|
cat "$cowsaidfile"
|
|
|
|
rm "$cowsaidfile"
|
2018-12-21 13:46:10 -06:00
|
|
|
}
|
|
|
|
trap trap_exit EXIT
|
|
|
|
while true; do
|
2018-12-21 15:26:17 -06:00
|
|
|
# Shut up shellcheck; that's the whole point. cowsay does a full read
|
|
|
|
# before it writes back to the file anyway.
|
|
|
|
# shellcheck disable=2094
|
|
|
|
cowsay -n < "$cowsaidfile" 1<> "$cowsaidfile"
|
|
|
|
printf "%s bytes of cowsay; hit Ctrl+C to dump them\\n" \
|
|
|
|
"$(stat --printf="%s" "$cowsaidfile")"
|
2018-12-21 13:46:10 -06:00
|
|
|
done
|