我在两个系统上有一个相同的文件,但是一个系统运行Debian 8,另一个系统运行11。
#!/bin/sh
### BEGIN INIT INFO
# Provides: warner
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
to=warning@blabla.com
subject="$1"
from=`hostname`@blabla.com
daemail=$(cat <现在在一个系统(deb8)上,它按预期工作,但在另一个系统上,我得到了一个错误
/etc/init.d/warner: 24: Syntax error: end of file unexpected (expecting ")")现在,当我在deb11脚本上将中断改为/bin/bash时,它就能工作了。为什么/bin/sh会在更新的Debian上抛出这个错误?
发布于 2022-10-27 20:42:31
我猜是在破折号0.5.7-4 (debian8.11)和破折号0.5.11-git+20200708之间发生了一些变化。(Debian 11),它影响了结束标记和终止子shell的方式。我认为,Debian符号链接/bin/sh到/bin/dash从Jessie (Debian 8)开始。
试着在“!”之后添加一个LF。将“)”移至下一行。
我从shellcheck.net那里得到的
Line 20:
!)
^-- SC1119 (error): Add a linefeed between end token and terminating ')'.https://serverfault.com/questions/1114169
复制相似问题