-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2306
Vidar Holen edited this page Nov 3, 2022
·
1 revision
f=$(expr "$c" * 9 / 5 + 32)
Prefer rewriting to a modern style (see SC2003):
f=$((c * 9 / 5 + 32))
If you do not wish to do so, at least escape the glob characters when passing them to expr
:
f=$(expr "$c" \* 9 / 5 + 32)
expr
is a command so expr 2 * 2
will consider *
to mean "all files in the current directory". This causes the expression to fail to evaluate unless you are in an empty directory with the failglob
and nullglob
options turned off.
Prefer rewriting it using the modern, POSIX standard arithmetic expansion $((..))
. If you do not wish to do so, you can escape any characters like *
to avoid the shell performing pathname expansion on them.
None
- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!