FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

SC2084 · koalaman/shellcheck Wiki · GitHub

SC2084 · koalaman/shellcheck Wiki · GitHub
Skip to content

Navigation Menu

Repository navigation

Joachim Ansorg edited this page Nov 12, 2021 · 3 revisions

Remove $ or use _=$((expr)) to avoid executing output.

Problematic code:

i=4
$(( i++ ))

Correct code:

Bash, Ksh:

i=4
(( i++ ))

POSIX (assuming ++ is supported):

i=4
_=$(( i++ ))

Alternative POSIX version that does not preserve the exit code:

: $(( i++ ))

Rationale:

$((..)) expands to a number. If it's the only word on the line, the shell will try to execute this number as a command name:

$ i=4
$ $(( i++ ))
4: command not found
$ echo $i
5

To avoid trying to execute the number as a command name, use one of the methods mentioned:

$ i=4
$ _=$(( i++ ))
$ echo $i
5

Exceptions:

None.

Wiki pages Pages 546

Clone this wiki locally

Footer

© 2026 GitHub, Inc.

Back | FazBrowse Home | New Git URL