gpt4 book ai didi

Bash,双引号和 "reboot"命令

转载 作者:行者123 更新时间:2023-11-29 09:36:11 25 4
gpt4 key购买 nike

假设您的 bash 脚本中有这两个语句:

# No. 1
MSG="Automatic reboot now."
echo $MSG

# No. 2
MSG=""Automatic reboot now.""
echo $MSG

语句编号 1 的输出符合预期(只是打印)。如果 bash 运行语句二,机器将重新启动(将执行任何有效的 bash 命令)。

但为什么呢?

最佳答案

那是因为 MSG=""Automatic reboot now."" 的含义如下:

Execute reboot now. with the env. var. MSG set to Automatic.

相当于:

MSG=Automatic reboot now.

关于Bash,双引号和 "reboot"命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50062071/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com