rust-lang/ferris-says

[Bug Report] Wrong line width when used with fortune

WenqingZong opened this issue · 1 comments

fsays failed to format long string when used with piped fortune.

└─(09:51:39 on wenqing ✹)──> fortune | fsays                                                                                                                                                          
 _________________________________________
/       My dear People.                         \
|       My dear Bagginses and Boffins, and my   |
| dear Tooks and Brandybucks,             |
| and Grubbs, and Chubbs, and Burrowses,  |
| and Hornblowers, and Bolgers,           |
| Bracegirdles, Goodbodies, Brockhouses   |
| and Proudfoots.  Also my good           |
| Sackville Bagginses that I welcome back |
| at last to Bag End.  Today is my        |
| one hundred and eleventh birthday: I am |
| eleventy-one today!"                    |
\               -- J. R. R. Tolkien                     /
 -----------------------------------------
        \
         \
            _~^~^~_
        \) /  o o  \ (/
          '_   -   _'
          / '-----' \

I think I figured out the reason: some fortune paragraphs contains \t, cowsay converts continues whitespaces into one space whereas fsays doesn't

minimal text to reproduce this bug:

											a								b

Note there are a lot of /ts before a and between a and b
cowsay output:

└─(16:24:43 on wenqing/fix_incorrect_width ✭)──> cat fortune6.txt | cowsay                                                                                                                  
 ______
<  a b >
 ------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

fsays output

└─(16:24:59 on wenqing/fix_incorrect_width ✭)──> cargo run -p fsays --release -- --files=fortune6.txt                                                                                       
    Finished release [optimized] target(s) in 0.00s
     Running `target/release/fsays --files=fortune6.txt`
 ____
<                                                                                       a                                                               b >
 ----
        \
         \
            _~^~^~_
        \) /  o o  \ (/
          '_   -   _'
          / '-----' \