![带有星号的 Systemd 转义错误发生在 shell 脚本中,但不在命令行中](https://linux22.com/image/228262/%E5%B8%A6%E6%9C%89%E6%98%9F%E5%8F%B7%E7%9A%84%20Systemd%20%E8%BD%AC%E4%B9%89%E9%94%99%E8%AF%AF%E5%8F%91%E7%94%9F%E5%9C%A8%20shell%20%E8%84%9A%E6%9C%AC%E4%B8%AD%EF%BC%8C%E4%BD%86%E4%B8%8D%E5%9C%A8%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%AD.png)
systemctl --user enable 'foo*'
从bash命令行运行成功;但是,将同一行放入 shell 脚本中并运行bash script
会产生结果
Invalid unit name "foo_*" was escaped as "foo_\x2a" (maybe you should use systemd-escape?)
Failed to enable unit: Unit file foo_\x2a.service does not exist.
注意我的systemctl
版本是239
.我见过这个问题的变体,但它们通常围绕 Windows 返回/回车问题(例子),而不是星号。