I have a script loaded as a service in /etc/init.d/myfileWhen I try to start the service I get the error/etc/init.d/myservice: 21: /etc/init.d/myservice: Syntax error: ( unexpectedThe issue seems to be with the process substitution <( in the source command. I use it without any problem in other scripts to extract variables from my main config file but inside a case statement I don't know how to make it work.myservice contains:#!/bin/sh#/etc/init.d/myservice### BEGIN INIT INFO# Provides:          myservice# Required-Start:    $remote_fs $syslog $network# Required-Stop:     $remote_fs $syslog# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: my service# Description:       Start the myservice service### END INIT INFOcase $1 in  start)    # start processes        # Import the following variables from config.conf: cfgfile, dir, bindir        source <(grep myservice /opt/mysoftware/config.conf | grep -oP '.*(?= #)')        if [ -f $cfgfile ]        then            echo Starting myservice            /usr/bin/screen -U -d -m $bindir/myscript.sh $cfgfile        else            echo myservice could not start because the file $cfgfile is missing        fi    ;;  stop)    # kill processes    echo Stopping myservice    screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill    ;;  restart)    # kill and restart processes    /etc/init.d/myservice stop    /etc/init.d/myservice start    ;;  *)    echo Usage: /etc/init.d/myservice {start|stop|restart}    exit 1    ;;esacexit 0The file config.conf is a list of variable declarations with a short description and the name of the script using them. I use grep filters to source only the variables I need for a given script.It looks like this:var1=value # path to tmp folder   myservicevar2=value # log file name        myservice script1.sh script2.shvar3=value # prefix for log file  script1.sh script2.shNote: The service worked fine before I converted it to start using the config file instead of hardcoded values.Thank you.
How to use process substitution within a case statement without getting syntax errors?
shell script;services;init.d;process substitution;case
Bash, ksh93, zsh, and other recent shells support process substitution (the <(command) syntax), but it is a non-standard extension. Dash (which is /bin/sh on Ubuntu systems) doesn't support it, and bash when invoked as /bin/sh doesn't, either.If you have bash available, change the first line of your script to, for example, #!/bin/bash . [On systems that have bash in a directory on a mountable filesystem, such as /usr/local/bin on some systems, you might need to make sure that filesystem is available before your service is started.]