Comment on Make bash show the return code by david

In reply to Fadi (itoctopus).

Sure. First let's reformat it:

The first thing we do is save the return code from $? into $ret, because subsequent commands, including [, will overwrite it. We then check if the return code is not equal to zero, i.e. is an error, and if so we print that string.

There isn't actually any hex codes - the "\033" is octal 33, which is the escape character in ASCII. This tells the terminal to start interpreting the next characters as ANSI escape codes. These can be quite complex, but you can generate them easily with the tput utility.

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论