mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2007 (markdown)
27
SC2007.md
Normal file
27
SC2007.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Use $((..)) instead of deprecated $[..]
|
||||||
|
|
||||||
|
### Problematic code
|
||||||
|
|
||||||
|
```sh
|
||||||
|
n=1
|
||||||
|
n=$[n+1]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code
|
||||||
|
|
||||||
|
```sh
|
||||||
|
n=1
|
||||||
|
n=$((n+1))
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rationale
|
||||||
|
|
||||||
|
The `$[..]` syntax was deprecated in Bash 2.0 and replaced with the standard `$((..))` syntax from Korn shell
|
||||||
|
|
||||||
|
### Exceptions
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
### See also
|
||||||
|
|
||||||
|
- http://unix.stackexchange.com/questions/209833/what-does-a-dollar-sign-followed-by-a-square-bracket-mean-in-bash
|
Reference in New Issue
Block a user