0

I have an identical file on two systems but one system is running Debian 8 and the other is 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 [email protected] subject="$1" from=`hostname`@blabla.com daemail=$(cat <<! From: $from To: $to Subject: $subject $2 You might want to check this... !) echo "$daemail" | /usr/sbin/sendmail -t 

Now on one system (deb8), it works as expected but on the other, I'm getting an error

/etc/init.d/warner: 24: Syntax error: end of file unexpected (expecting ")") 

Now when I change the interpter to /bin/bash on the deb11 script, it works. Why the /bin/sh throws this error on newer Debian?

1 Answer 1

0

I'm guessing some changes were made between dash 0.5.7-4 (Debian 8.11) and dash 0.5.11-git+20200708... (Debian 11) that have affected how end tokens and terminating a sub-shell. Debian symlinks /bin/sh to /bin/dash since before Jessie (Debian 8) I think.

Try adding a LF after the '!' to move the closing ')' to the next line.

I got this from shellcheck.net

Line 20: !) ^-- SC1119 (error): Add a linefeed between end token and terminating ')'. 
1

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.