我有以下问题,我正在编写一个创建 fifo 设备文件的脚本,但即使文件已经存在,我也想返回 true。以下代码段试图从||
和 中创建fifos /bin/true
。我怎么能告诉mkfifo
cmd 最后一个参数是X
?
$ /usr/bin/mkfifo /dev/fifofile || /bin/true
Run Code Online (Sandbox Code Playgroud)
在 systemd 服务中运行它:
ExecStartPre=/usr/bin/mkfifo /dev/fifofile || /bin/true
Run Code Online (Sandbox Code Playgroud)
Apr 29 08:39:40 mkfifo[27275]: /usr/bin/mkfifo: cannot create fifo '/dev/fifofile': File exists
Apr 29 08:39:40 mkfifo[27275]: /usr/bin/mkfifo: cannot create fifo '||': File exists
Apr 29 08:39:40 mkfifo[27275]: /usr/bin/mkfifo: cannot create fifo '/bin/true': File exists
Run Code Online (Sandbox Code Playgroud)
尝试更改ExecStartPre
toExecStartPre=(/usr/bin/mkfifo /dev/fifofile) || /bin/true
会出现以下错误:
Executable path is not absolute: (/usr/bin/mkfifo /dev/gpsfifo) || /bin/true
Run Code Online (Sandbox Code Playgroud)