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:ccmd:conditional_expression [2017/02/01 05:54]
fgrose [Table] Provide link to arithmetic comparisons and expression command
syntax:ccmd:conditional_expression [2017/02/08 22:30] (current)
fgrose [Table] highlight the consequence of quoting a PATTERN
Line 15: Line 15:
 | ''<​EXPRESSION1>​ **&&​** <​EXPRESSION2>'' ​                             | ''​TRUE''​ if ''<​EXPRESSION1>''​**and**''<​EXPRESSION2>''​ are ''​TRUE''​ (do **not** use ''​-a''​!) ​                                                                         | | ''<​EXPRESSION1>​ **&&​** <​EXPRESSION2>'' ​                             | ''​TRUE''​ if ''<​EXPRESSION1>''​**and**''<​EXPRESSION2>''​ are ''​TRUE''​ (do **not** use ''​-a''​!) ​                                                                         |
 | ''<​EXPRESSION1>​ **||** <​EXPRESSION2>'' ​                             | ''​TRUE''​ if ''<​EXPRESSION1>''​**or**''<​EXPRESSION2>''​ is ''​TRUE''​ (do **not** use ''​-o''​!) ​                                                                           | | ''<​EXPRESSION1>​ **||** <​EXPRESSION2>'' ​                             | ''​TRUE''​ if ''<​EXPRESSION1>''​**or**''<​EXPRESSION2>''​ is ''​TRUE''​ (do **not** use ''​-o''​!) ​                                                                           |
-| ''<​STRING>​ **==** <​PATTERN>'' ​                                      | ''<​STRING>''​ is checked against the pattern ''<​PATTERN>''​ - ''​TRUE''​ on a match                                                                                      |+| ''<​STRING>​ **==** <​PATTERN>'' ​                                      | ''<​STRING>''​ is checked against the pattern ''<​PATTERN>''​ - ''​TRUE''​ on a match \\    //But note¹, quoting the pattern forces a literal comparison.// ​               ​|
 | ''<​STRING>​ **=** <​PATTERN>'' ​                                       | equivalent to the ''​==''​ operator ​                                                                                                                                   | | ''<​STRING>​ **=** <​PATTERN>'' ​                                       | equivalent to the ''​==''​ operator ​                                                                                                                                   |
 | ''<​STRING>​ **!=** <​PATTERN>'' ​                                      | ''<​STRING>''​ is checked against the pattern ''<​PATTERN>''​ - ''​TRUE''​ on **no match** ​                                                                                | | ''<​STRING>​ **!=** <​PATTERN>'' ​                                      | ''<​STRING>''​ is checked against the pattern ''<​PATTERN>''​ - ''​TRUE''​ on **no match** ​                                                                                |
Line 23: Line 23:
  
  
-When the ''​==''​ and ''​!=''​ operators are used, the string to the right of the operator is considered a pattern and matched according to the rules of [[syntax:​pattern | Pattern Matching]]. If the shell option ''​nocasematch''​ is enabled, the match is performed without regard to the case of alphabetic characters. ​Any part of the pattern may be quoted to force it to be  +When the ''​==''​ and ''​!=''​ operators are used, the string to the right of the operator is considered a pattern and matched according to the rules of [[syntax:​pattern | Pattern Matching]]. If the shell option ''​nocasematch''​ is enabled, the match is performed without regard to the case of alphabetic characters. 
-matched as a literal string.+ 
 +¹Any part of the pattern may be quoted to force it to be matched as a literal string.
  
 When the operators ''<''​ and ''>''​ are used (string collation order), the test happens using the current locale when the ''​compat''​ level is greater than "​40"​. When the operators ''<''​ and ''>''​ are used (string collation order), the test happens using the current locale when the ''​compat''​ level is greater than "​40"​.
  • syntax/ccmd/conditional_expression.1485928445.txt
  • Last modified: 2017/02/01 05:54
  • by fgrose