-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
script.Exec - no colours on stdout #168
Comments
Hi, @indaco, thanks for the report! Most programs that produce coloured output can also detect whether or not they're talking to an interactive terminal (for example, In this case, the output of |
Hi @bitfield thanks for the proper response. For sure, I'm in wrong but...the reason why I am asking how to achieve it with script is simply because, using something like package main
func ExecCmd(cmdName string, cmdOptions string, silentMode bool) error {
var cmd *exec.Cmd
args := strings.Split(cmdOptions, " ")
cmd = exec.Command(cmdName, args[0:]...)
cmd.Stderr = os.Stderr
if !silentMode {
cmd.Stdout = os.Stdout
}
err := cmd.Start()
if err != nil {
return err
}
return cmd.Wait()
} I got the output with colours preserved. if you try it with e.g. err := ExecCmd("pnpm", "install", false)
if err != nil {
fmt.Println(err.Error())
} What am I missing? |
Your code sets the command's By contrast, in a
|
Got the point, I guess, thanks. One more... My initial thought was pipe := script.NewPipe().WithStdout(os.Stdout)
pipe.exec("...").Stdout() would get the same result of my code, then going thought the documentation
sets the pipe's standard output to the writer w, instead of the default Does it mean the default I am missing something, no doubts...buggy brain |
This has no effect on the standard output of commands run by If setting |
yes, setting I was trying to understand...anyhow, thanks for your time and for the script package. I'm going to replace my custom code with it. |
Executing system commands printing colourful messages on stdout, the output does not preserve the colours.
How to do that?
Thanks
The text was updated successfully, but these errors were encountered: