mac

Differences

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

Link to this comparison view

Next revision
Previous revision
mac [2012/02/10 02:17]
drkrimson created
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 16: Line 17:
 \e[1m bold \e[0m \e[1m bold \e[0m
 </​code>​ </​code>​
 +
 WTH? I thought as I tried some other escapes ( ''​\n \t \a''​ ) and without problem the newline, the tab and the sysbeep/​bell sounded. WTH? I thought as I tried some other escapes ( ''​\n \t \a''​ ) and without problem the newline, the tab and the sysbeep/​bell sounded.
-//Ok, I thought, maybe escape is disabled on some level.. but just out of, mainly boredom, I tried to ''​\033[1m give the octal value of \e033[0m escape ''​ and Lo-and-Behold:​ ''​ **give the octal value of ** escape'' ​ 
  
-Now I started getting REALLY confused.... why block the one (\e) and not the other... ​ 
-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. :)+//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>​ 
 +and Lo-and-Behold,​ it printed it proper:  
 + 
 +''​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 (\033)... 
 + 
 +  
 +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.1328840257.txt
  • Last modified: 2012/02/10 02:17
  • by drkrimson