mac

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
mac [2012/02/10 02:20]
drkrimson
mac [2012/02/10 02:28] (current)
drkrimson echo -e "\e" vs echo -e "\033" vs echo $'\e'
Line 8: Line 8:
  
 **echo -e weirdness** **echo -e weirdness**
 +
 Something I came across today while testing some bash-4.2 scripts on a mac; to print some text in bold I used the ancient ansi escape sequence <​ESC>​[1m. Something I came across today while testing some bash-4.2 scripts on a mac; to print some text in bold I used the ancient ansi escape sequence <​ESC>​[1m.
  
Line 22: Line 23:
 //Ok//, I thought, //maybe escape is disabled on some level//.. but just out of curiosity, and a healthy dose of boredom, I tried to //Ok//, I thought, //maybe escape is disabled on some level//.. but just out of curiosity, and a healthy dose of boredom, I tried to
 <​code>​ echo -e "So what if I \033[1m give the octal value of \e033[0m escape"</​code>​ <​code>​ echo -e "So what if I \033[1m give the octal value of \e033[0m escape"</​code>​
-and Lo-and-Behold,​ it printed it proper+and Lo-and-Behold,​ it printed it proper
  
 ''​So what if I **give the octal value of ** escape'' ​ ''​So what if I **give the octal value of ** escape'' ​
  
  
-Now I started getting REALLY confused.... why block the one (\e) and not the other...  +Now I started getting REALLY confused.... why block the one (\e) and not the other (\033)...
-So I tried a ''​echo $' why dont u \e[1mW0RK\e[0m ??' ''​ and, of course, because who ever wanted consistency from their computers the ol' $'​string'​ syntax DID give me bold.+
  
-If anyone knows which setting, flag, version or environment ​influence somesuch has this effect.. ​Please ​**DO** let me know. :)+  
 +But that wasn't even the annoying bit, even though my bash refuses to acknowledge the existence of \e in a ''​echo -e''​ double quoted string,  
 + 
 +It has **no** problem giving me my beloved \e when I use a $'​string'​ 
 + 
 +That's right: 
 +<​code>​ 
 +echo $' why dont u \e[1m W0RK \e[0m'​ 
 +</​code>​  
 +gave me nice and proper  
 + 
 +''​why dont u **W0RK** ''​ 
 + 
 + 
 +I guess someone at apple didn't like consistency too much or something. ^^ 
 + 
 +If anyone knows which setting, flag, version or environment ​variable van have this effect.. ​ 
 +And/or how to fix it, please ​**DO** let me know. :)
  
 /rant /rant
 +
 Krim Krim
--- + 
-Don't even get me started about ''​printf "​%(%Y-%m-%d)T"​ -1'' ​;)+--  
 +Don't even get me started about ''​printf "​%(%Y-%m-%d)T"​ -1''​
  • mac.1328840434.txt
  • Last modified: 2012/02/10 02:20
  • by drkrimson