sh 脚本中的 ${Tmp0} 是什么?
在 shell 脚本中,我发现了以下代码行:
rm -f "${Tmp0}"
这是脚本中的第一行之一,我不熟悉 Tmp0 变量。它是到特定内容的 shell 标准映射吗?我做了一些谷歌搜索,但似乎找不到好的解释。
我怀疑这是脚本的先前版本的剩余部分(不需要查看整个内容,它是无关紧要的),因为我在其中的其他任何地方都看不到对此变量的任何引用。
In a shell script, I found the following line of code:
rm -f "${Tmp0}"
It is one of the first lines in the script, and I'm not familiar with the Tmp0 variable. Is it a shell standard mapping to something specific? I did some Google searches and I can't seem to find good explanation.
I suspect this is a leftover from a previous version of the script (no need to see the whole thing, it's irrelevant), since I can't see any reference to this variable anywhere else in it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它没有预定义的含义,但这并不意味着它没有用。如果有人在调用此脚本之前导出此变量,它将删除定义的文件。此外,如果此脚本
source
是另一个文件,则该变量可能会在那里定义。无论如何,如果这两个条件都不成立,那么它确实可能是一个剩余物。
It doesn't have predefined meaning, but that doesn't mean it's useless. If someone exports this variable before calling this script it will delete the defined file. Also if this script
source
s another file, this variable might be defined there.Anyway, if none of the two conditions hold true, then it indeed might be a leftover.
变量
${Tmp0}
没有标准含义。通常,在此之前会有一个对
Tmp0
的赋值,例如:如果赋值不可见,那么它可能是某种剩余的碎片,或者某人没有非常仔细地选择环境变量命名方案(以及对文件的有些可疑的处理;无条件删除文件的脚本很少长期流行)。
There is no standard meaning for the variable
${Tmp0}
.Usually, there'd be an assignment to
Tmp0
before that, such as:If the assignment isn't visible, then it is probably leftover debris of some sort, or someone's not very careful chosen environment variable naming scheme (and somewhat dubious handling of files; scripts that go around deleting files unconditionally are seldom popular for long).
如果您是这个意思,那么这不是 shell 的硬编码变量。
您可以在代码中添加一个简单的调试来打印变量的内容,该信息可能会为您提供一些有关其用途的线索:
That's not a hard-coded variable of the shell, if that's what you meant.
You can add a simple debug to the code to print the content of the variable and that information might give you some clues on it's purpose: