C code in Bash?

Hi everyone, in better attempts to learn Bash shell scripting I've been looking at and reviewing people's bash shell scripts on Github. I'm still reviewing "easier" scripts, trying to follow the logic, syntax etc..

I came across this very odd syntax and it really puzzled me.

echo -e "\033[91mVulnerable to $1\033[39m"
echo -e "\033[93mFound non-exploitable $1\033[39m"

What's all of this \033 and [39m business about?

Upon Googling, I see that it has something to do with C code about line syntax? Does anyone know what this does exactly? Does it have to do with formatting the output?

This brings up a larger question in that can you use C syntax and commands like this in a BASH script? Why would some C code work and others not?

It's nothing to do with C.

The -e, in some very specific versions of the bourne shell, means "enable escape sequences", including octal ones, of the form backslash-zero-digit-digit[-digit]. In most other versions of the Bourne shell, the -e and the backslashes and everything will be dumped literally. printf, though, does support these sequences almost everywhere.

The [91m bit has nothing to do with C or BASH. It just prints a literal [, 9, 1, m. But a terminal supporting ANSI escape sequences will take octal 33, followed by [, 9, 1, m, to mean "change color to bright red".

The 39m means 'switch back to grey', which is a little wrong, as the appropriate thing to do is a reset to default, not what you assume the default to be.

Look into man console_codes (might be limited to linux). The \033 is the octal representation of the ESC char (used to introduce the codes), and echo 's -e option makes it interpret such control chars.

Wow, I've been in and out of linux scripting for like a year now...but I've yet to ever hear of this... Thanks guys! Is this deprecated syntax for bash? Really I don't see the point of it though...

The point is:

linux ls command output in colors
cursor positioning
bolding text
highlighting text - like info command output