sckott / cowsay

cowsay w/ more animals, in R

Home Page:https://sckott.github.io/cowsay/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prints everything to stderr instead of stdout

mye opened this issue · comments

This example prints nothing if run in bash:

Rscript - 2>/dev/null <<!
library(cowsay)
say("Hello, Kitty!", "stretchycat")
!

It means that even the kitty is going to stderr, which is IMO unexpected.

I found this after trying to silence an annoying "error" message that seems
to be printed unconditionally if the crayon package isn't run on a color terminal.

Colors cannot be applied in this environment :( Try using a terminal or RStudio.

I would humbly request to not treat animals as if they were errors, which is surely not in the spirit of this package, and to respect people who pefer uncolored pets on their text terminals by default (don't print the message, just don't output colors in this case).

thanks for the issue @mye

@aedobbyn do you have any knowledge in this area?

two things: 1) i'm not sure i know how to send output to stdout instead of stderr, and 2) even if there's a straight-forward way to do it, what is best practice for a) interactive, and b) non-interactive usage?

Ooh hm I'm not sure off the bat. But I agree with you @mye that's probably annoying to get that message every time. If we changed

cowsay/R/say.r

Line 135 in 0c8dad1

if (crayon::has_color() == FALSE) {
to

if (crayon::has_color() == FALSE && (!is.null(what_color) || !is.null(by_color)))

I think we at least solve that issue

Okay so according to the first answer here, message prints to stderr by default where as print and cat got to stdout.

So we could add a new type called "print" and put something in such that when interactive() is false, default to the "print" type.

Why does it have to be stderr in interactive mode? (Maybe something about R I'm not aware of, but I don't see the point in putting the expected output on stderr).

So we could add a new type called "print" and put something in such that when interactive() is false, default to the "print" type.

sounds good @aedobbyn

@mye i don't know, that's just the way R is. i think we'd want to maintain idiomatic R here, while using @aedobbyn suggestion for non-interactive mode