bash - 为什么 Pycharm 在 .sh bash 脚本中对 "simple variable usage"发出警告?

标签 bash pycharm

<分区>

在 Pycharm 中,当我们使用变量时,例如$privateKey,我们收到警告 Simple variable usage 如下图,建议我们转向语法 ${privateKey}

我的问题是为什么我们会收到这样的警告?使用这样的简单变量有什么风险?

enter image description here

点击more

enter image description here

最佳答案

感谢@Whymarrh。一answer如下所示。

since "$foobar" would instead expand foobar

我的答案是在字符串 "$myVarnotInVar" 中分隔/区分 $myVarnotInVar

换句话说

myVar=122

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

echo "${myVar}notInVar" # will print 122notInVar

关于bash - 为什么 Pycharm 在 .sh bash 脚本中对 "simple variable usage"发出警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40581956/

相关文章:

unit-testing - Pycharm 单元测试交互式调试命令行不起作用

Python shebang 和换行符

mysql - Bash 脚本 - 错误 1 ​​(HY000) - 从数据库保存表

python - 当指定绝对路径 $/usr/bin/python 与 $ python 别名为相同路径时,如何会产生不同的结果?

javascript - 如何在 Pycharm/Intellij 中打印到 javascript 控制台

python - 错误 : Could not build wheels for PyNaCl which use PEP 517 and cannot be installed directly

PyCharm 远程选项不可用

bash - -n 和 -g 在排序上有什么区别?

bash - 为什么在此bash脚本中执行顺序相反?

python - 防止 flask 在变化时重新加载