Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next 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/06 23:55] fgrose [Description] Added note on quoted <PATTERN> forcing literal matching |
||
---|---|---|---|
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 see the note on quoting the pattern below¹. | |
| ''<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". |