Search code examples
linuxbashshellcurlpiping

Preserve colors while piping setup script from CURL to BASH


I am currently running a vbox provisioner with curl -sSL http://goo.gl/DGs3Fv |bash and noticed that I am losing my tty coloring while doing so. Is there anyway to fix this without porting into a variable and echoing out "after the fact"?

I've tried the answer in Can colorized output be captured via shell redirect? but this does not seem to work in my situation. Thanks.

Quick example

Run as CURL

Run as Shell


Solution

  • It appears that your distro's init scripts are checking stdin to determine whether to output colors to stdout, and if so that's a bug on their side.

    The answer you link to is right, you should be able to work around it with script:

    curl -sSL http://goo.gl/DGs3Fv | script -c 'bash' -q /dev/null
    

    Running script .. curl | bash wouldn't work though, since it's bash and not curl you're trying to fool.