piuccio/cowsay

Border formatting problem

gene-pavlovsky opened this issue · 2 comments

You can see the border is too small for the entire message. Looks like it was sized according to the first line, not the widest line. (COLUMNS is 148 so I doubt that matters). I've confirmed same issue with other fortunes, on the author's line. Is it possible the author's line is indented with tab(s), and cowsay doesn't take tab width into account?

# fortune | cowsay -W $COLUMNS
 _______________________
/ I am two with nature. \
\               -- Woody Allen      /
 -----------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

I do think it's a tab issue, since replacing tabs with 8 spaces before piping input to cowsay fixes the problem.
{ echo; fortune -a; } | tr '\t' ' ' | cowsay -n -f squirrel

The border is computed on the longest line, however tabs are considered as single space character. Feel free to send a PR 😆