Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
clonedagain opened this issue Feb 13, 2018 · 1 comment

Comments

@clonedagain
Copy link
Contributor

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

@loxaxs
Copy link

loxaxs commented May 6, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants