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
syntax:pe [2014/04/01 07:26]
ormaaj [Bugs and Portability considerations] Add a section on the quote nesting PE problem
syntax:pe [2018/07/24 19:53] (current)
nicolae Fixed typo
Line 78: Line 78:
 __Why does the first one fail?__ It prints nothing, because a parameter (variable) named "''​WORDs''"​ is undefined and thus printed as ""​ (//​nothing//​). Without using braces for parameter expansion, Bash will interpret the sequence of all valid characters from the introducing "''​$''"​ up to the last valid character as name of the parameter. When using braces you just force Bash to **only interpret the name inside your braces**. __Why does the first one fail?__ It prints nothing, because a parameter (variable) named "''​WORDs''"​ is undefined and thus printed as ""​ (//​nothing//​). Without using braces for parameter expansion, Bash will interpret the sequence of all valid characters from the introducing "''​$''"​ up to the last valid character as name of the parameter. When using braces you just force Bash to **only interpret the name inside your braces**.
  
-Also, please remember, that **parameter names are** (like nearly everything in UNIX(r)) **case ​sentitive!**+Also, please remember, that **parameter names are** (like nearly everything in UNIX(r)) **case ​sensitive!**
  
 The second form with the curly braces is also needed to access positional parameters (arguments to a script) beyond ''​$9'':​ The second form with the curly braces is also needed to access positional parameters (arguments to a script) beyond ''​$9'':​
Line 100: Line 100:
 ''​${!PARAMETER}''​ ''​${!PARAMETER}''​
  
-In come cases, like for example+In some cases, like for example
  
 <​code>​ <​code>​
Line 192: Line 192:
     * => ''​THIS IS SOME TEXT''​     * => ''​THIS IS SOME TEXT''​
    * ''​echo "​${array[2]^^}"''​    * ''​echo "​${array[2]^^}"''​
-     * => ''​TEXT''​+     * => ''​SOME''​
  
 ===== Variable name expansion ===== ===== Variable name expansion =====
Line 325: Line 325:
 echo ${MYSTRING/​%x/​y} ​ # RESULT: xxxxxxxxxy</​code>​ echo ${MYSTRING/​%x/​y} ​ # RESULT: xxxxxxxxxy</​code>​
  
-If the replacement part is completely omitted, like, the matches are replaced by the nullstring, i.e. they are removed. This is equivalent to specifying an empty replacement:​+If the replacement part is completely omitted, the matches are replaced by the nullstring, i.e.they are removed. This is equivalent to specifying an empty replacement:​
 <​code>​ <​code>​
 echo ${MYSTRING//​conservative/​} echo ${MYSTRING//​conservative/​}
Line 356: Line 356:
  
 => ''​64''​ => ''​64''​
 +
 +The length is reported in characters, not in bytes. Depending on your environment this may not always be the same (multibyte-characters,​ like in UTF8 encoding).
  
 There'​s not much to say about it, mh? There'​s not much to say about it, mh?
Line 775: Line 777:
 <​myCmd>​ <​arg1>​ <​arg2>​ <​yay!>​ <​third*arg*>​ <4> <​arg5>​ <​myCmd>​ <​arg1>​ <​arg2>​ <​yay!>​ <​third*arg*>​ <4> <​arg5>​
  
-# ...Ah fuck. (again, no workaround possible.)+# ...Ah f^^k. (again, no workaround possible.)
 </​code>​ </​code>​
  
  • syntax/pe.1396337188.txt
  • Last modified: 2014/04/01 07:26
  • by ormaaj