Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Pycharm gives warning on "simple variable usage" in .sh bash script? [duplicate]

Tags:

bash

pycharm

In Pycharm when we use variable e.g. $privateKey, we get the warning Simple variable usage as below snapshot and recommend us to turn to the syntax ${privateKey}

My question is why we get such warning? What is the risk to use simple variable like that?

enter image description here

When clicking more

enter image description here

like image 950
Nam G VU Avatar asked Nov 14 '16 04:11

Nam G VU


1 Answers

Thanks to @Whymarrh. One answer is as below.

since "$foobar" would instead expand foobar

My answer is to separate/distinguish $myVar and notInVar in string "$myVarnotInVar"

In other words

myVar=122

echo "$myVarnotInVar" # will print empty string "" since undefined variable $myVarnotInVar

echo "${myVar}notInVar" # will print 122notInVar
like image 192
Nam G VU Avatar answered Nov 16 '22 03:11

Nam G VU