cowsay-org / cowsay

apjanke's fork of the classic cowsay project
http://cowsay.diamonds
GNU General Public License v3.0
83 stars 15 forks source link

Parseable output for `cowsay -l` #9

Closed apjanke closed 4 years ago

apjanke commented 4 years ago

The cowsay -l output has some human-readable header junk in it:

$ ./cowsay -l
Cow files in ./share/cows:
beavis.zen blowfish bong bud-frogs bunny cheese cower daemon default dragon
dragon-and-cow elephant elephant-in-snake eyes flaming-sheep ghostbusters
head-in hellokitty kiss kitty koala kosh llama luke-koala meow milk moofasa
moose mutilated ren satanic sheep skeleton small sodomized stegosaurus
stimpy supermilker surgery telebears three-eyes turkey turtle tux udder
vader vader-koala www

That means you can't really just capture its output in a bash variable and loop over it or random-index into it.

Add a more parsing-friendly -l output format, triggered either when the output is attached to a non-terminal device, or with another option flag.

apjanke commented 4 years ago

Done in https://github.com/cowsay-org/cowsay/commit/772f079b8a5685b96d5cb11a213be908d401f62a.

$ ./cowsay -l | cat
DragonAndCow
Example
Frogs
MechAndCow
Stegosaurus
TextBalloon
TuxStab
beavis.zen
blowfish
bong
bud-frogs
bunny
cheese
cower
daemon
default
dragon
dragon-and-cow
elephant
elephant-in-snake
eyes
[...]

I also fixed the problem of cowsay -l ignoring *.pm files.