Why does Pycharm give a “simple variable usage” warning in a .sh bash script?

In Pycharm, when we use a variable, for example. $privateKey we get a warning Using a simple variable as shown below snapshot and recommend that we refer to the syntax ${privateKey}

My question is why do we get such a warning? What is the risk of using a simple variable?

enter image description here

By clicking more

enter image description here

+9
source share
1 answer

Thanks @Whymarrh. One answer as below.

since "$ foobar" will expand foobar instead

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

In other words

 myVar=122 echo "$myVarnotInVar" # will print empty string "" since undefined variable $myVarnotInVar echo "${myVar}notInVar" # will print 122notInVar 
+4
source

Source: https://habr.com/ru/post/1259703/


All Articles