This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision |
vcs:devel:bash_support [2010/08/28 02:23] – New possible syntax Toni Corvera | vcs:docs:devel:bash_support [2016/04/17 23:28] (current) – ↷ Page moved from dox:vcs:devel:bash_support to vcs:docs:devel:bash_support Toni Corvera |
---|
| |
* ''for <nowiki>((;;))</nowiki>'': C-style for. Loops in bash are *really* slow, an inline AWK loop, is much faster | * ''for <nowiki>((;;))</nowiki>'': C-style for. Loops in bash are *really* slow, an inline AWK loop, is much faster |
* ''<nowiki>[[ ... ]]</nowiki>'': ''test'' replacement. Builtin with cleaner syntax and parsing, no need to quote, grouping (parentheses), ''&&'' and ''||'' instead of ''-a'' and ''-o'', arithmetic operators (e.g. ''-eq'') force arithmetic evaluation (i.e. <nowiki>[[ 2 -eq "1+1" ]]</nowiki> is true): \\ ''[ "$VAR" = "$X" -a 2 -eq <nowiki>$(( 1+1 ))</nowiki> ]'' -> ''<nowiki>[[ $VAR = $X && 2 -eq '1+1' ]]</nowiki>'' | * ''<nowiki>[[ ... ]]</nowiki>'': ''test'' replacement. Builtin with cleaner syntax and parsing, no need to quote, grouping (parentheses), ''&&'' and ''||'' instead of ''-a'' and ''-o'', arithmetic operators (e.g. ''-eq'') force arithmetic evaluation (i.e. <nowiki>[[ 2 -eq "1+1" ]]</nowiki> is true): \\ ''[ "$VAR" = "$X" -a 2 -eq <nowiki>$(( 1+1 ))</nowiki> ]'' -> ''<nowiki>[[ $VAR = $X && 2 -eq '1+1' ]]</nowiki>'' \\ **Pitfall**: When unquoted, the right hand side of a text comparison ('=', '==' and '!=') is considered a pattern ((http://wiki.bash-hackers.org/syntax/ccmd/conditional_expression)) ((http://wiki.bash-hackers.org/syntax/pattern)) |
| |
====== Syntax in 3.1 ====== | ====== Syntax in 3.1 ====== |
| |
* ''caller'': ''caller 0'' prints the calling function and line | * ''caller'': ''caller 0'' prints the calling function and line |
| * ''<nowiki>[[ =~ ]]</nowiki>'': Pattern matching (right side can be an extended regular expression) ((http://wiki.bash-hackers.org/syntax/ccmd/conditional_expression)) \\ **Pitfalls**: when quoted, it isn't considered an ERE in bash 3.2 and up, but it is in bash 3.1. A variable can be used to get the same behaviour or the shell settings ''shopt compat31'' / ''shopt compat32'' be used. |
| |