ponysay icon indicating copy to clipboard operation
ponysay copied to clipboard

ponysay -l should not print bold names when piped to another command (Ansible)

Open clonedagain opened this issue 7 years ago • 1 comments

Currently, ponysay prints some names in bold when called with -l, +l, -L, -A, +A.

It becomes a problem when trying to post-process the output, for example build a list of ponies to choose from.

For example, I like to link ponysay instead of cowsay, and enjoy it when using Ansible, but that restricts me to the non-bold pony names. That's because Ansible calls "cowsay -l" to get list of cows and filter using a whitelist, and it can't remove the escape codes : https://github.com/ansible/ansible/blob/e9b0a4ccb42854329b33b06624379c6122b67bd7/lib/ansible/utils/display.py#L99

clonedagain avatar Feb 13 '18 14:02 clonedagain

In https://gist.github.com/loxaxs/5a318bc347fb7c77c2757cc7011ae468, I had to use a hack to avoid the problem.

I piped the output through sed 's/\x1b\[[0-9;]*m//g' to remove the escape sequences. If you need to remove the name alias between parenthesis (as I did), you might want to use sed 's/\x1b\[[0-9;]*m//g;s/(.*)//g' instead.

loxaxs avatar May 06 '19 14:05 loxaxs