Home > Enterprise >  Escape sequences \033[01;36m\] vs. \033[1;36m\] in PS1 in .bashrc: why the zero?
Escape sequences \033[01;36m\] vs. \033[1;36m\] in PS1 in .bashrc: why the zero?

Time:11-06

I've just compared the $PS1 prompts in .bashrc on two of my Debian machines:

PS1='${debian_chroot: ($debian_chroot)}\[\033[01;36m\]\u\[\033[0;90m\]@\[\033[0;32m\]\h\[\033[0;90m\]:\[\033[01;34m\]\w\[\033[0;90m\]\$\[\033[0m\] '

PS1='${debian_chroot: ($debian_chroot)}\[\033[1;36m\]\u\[\033[0;37m\]@\[\033[0;32m\]\h\[\033[0;37m\]:\[\033[01;34m\]\w\[\033[0;37m\]\$\[\033[0m\] '

As you see, the first sequence says \033[01;, whereas the second has \033[1; on the same position. Do both mean the same (I guess, bold) or do they mean something different? Any idea why the zero has appeared or disappeared? I have no recollection of having introduced/removed this zero myself. A Web search returns numerous occurrences both with and without zero.

CodePudding user response:

the ESC[#;#m escape is for the console font color. I've seen many subtle variations on escape implementations, so I'm not surprised. Regardless I think both should be interpreted the same way

CodePudding user response:

"ANSI" numeric parameters are all decimal integers (see ECMA-48, section 5.4.1 Parameter Representation). In section 5.4.2, it explains

A parameter string consists of one or more parameter sub-strings, each of which represents a number in decimal notation.

A leading zero makes no difference. Someone noticed the unnecessary character and trimmed it.

  • Related