cowsayeternal: Use a temporary file to circumvent argument size restrictions
This commit is contained in:
parent
4559167e88
commit
dcfc977fc0
@ -1,10 +1,16 @@
|
||||
#!/bin/bash
|
||||
cowsaid="$(cowsay "E T E R N A L")"
|
||||
cowsaidfile="$(mktemp)"
|
||||
cowsay "E T E R N A L" > "$cowsaidfile"
|
||||
trap_exit() {
|
||||
printf "%s" "$cowsaid"
|
||||
cat "$cowsaidfile"
|
||||
rm "$cowsaidfile"
|
||||
}
|
||||
trap trap_exit EXIT
|
||||
while true; do
|
||||
cowsaid="$(cowsay -n <<< "$cowsaid")"
|
||||
printf "%s characters of cowsay; hit Ctrl+C to dump them\\n" "$(wc -c <<< "$cowsaid")"
|
||||
# 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")"
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user