Shell arithmetic expansion #282

Closed
fredericopissarra opened this Issue Apr 20, 2016 · 3 comments

Projects

None yet

3 participants

@fredericopissarra
Contributor

Both bash and sh documentation (Linux) says that $[expression] is an old syntax. They prefeer $((expression)). bash manpage says:

"The old format $[expression] is deprecated and will be removed in upcoming versions of bash."

sh manpage shows only $((expression)) syntax, not $[expression].

@ktsaou
Member
ktsaou commented Apr 20, 2016

nice!

@ktsaou ktsaou added the enhancement label Apr 20, 2016
@glensc
Contributor
glensc commented Apr 20, 2016

$[] is not only old, but not present in posix, and thus not all shells support it:

$ mksh -c 'echo $[1+1]; echo $((1+1));'
$[1+1]
2
@simonnagl simonnagl added a commit to simonnagl/netdata that referenced this issue Apr 28, 2016
@simonnagl simonnagl Fix #282 use modern arithmetic expansion in shell
Use $((.*)) instead of $[.*]
The later one is old syntax
8707708
@simonnagl simonnagl added a commit to simonnagl/netdata that referenced this issue Apr 29, 2016
@simonnagl simonnagl Fix #282 use modern arithmetic expansion in shell
Fix also files not ending with .sh
Use $((.*)) instead of $[.*]
The later one is old syntax
a9d5e45
@simonnagl simonnagl added a commit to simonnagl/netdata that referenced this issue Apr 29, 2016
@simonnagl simonnagl Fix #282 use modern arithmetic expansion in shell
Fix also files not ending with .sh
Use $((.*)) instead of $[.*]
The later one is old syntax
316ff7d
@ktsaou ktsaou pushed a commit that closed this issue Apr 29, 2016
@simonnagl simonnagl Fix #282 use modern arithmetic expansion in shell
Use $((.*)) instead of $[.*]
The later one is old syntax
ec28e63
@ktsaou ktsaou closed this in ec28e63 Apr 29, 2016
@ktsaou ktsaou added the fixed label Apr 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment