problems with sh after upgrade to 4.7
Konrad Heuer
kheuer2 at gwdg.de
Wed Apr 30 02:52:53 PDT 2003
On Wed, 30 Apr 2003, Gunnar Flygt wrote:
> After upgrade from 4.6.2-RELEASE to 4.7-RELEASE I've got problems
> with a shellscript that I have on one of my machines. The script
> (which I've taken over from a far better shellprogammer) looks as follows:
>
> #!/bin/sh
> [...snip...]
>
> The problem line is line 12:
> [ -x ${RTSPPROXY} ] && ${RTSPPROXY} > /dev/null & && echo $! > $ {PID_FILE}
>
> When I run `/usr/local/etc/rc.d/rtspproxy.sh start I get this error
>
> /usr/local/etc/rc.d/rtspproxy.sh: 12: Syntax error: "&&" unexpected
>
> The script starts the file and redirects the output from rtspproxy
> (the PID) to the PID_FILE so that the check part can use it later.
>
> Since my knowledge in shellscripting is not enough to rewrite the script,
> I ask for help here.
It's no longer legal to combine & and && since the return code of a
background process cannot be verified by the shell in order to decide
whether commands after && should be executed.
I'd suggest to replace the critical line by:
[ -x ${RTSPPROXY} ] && ${RTSPPROXY} > /dev/null &
if [ -n "$!" ]; then echo $! > ${PID_FILE}; else rm -f ${PID_FILE}; fi
Regards
Konrad Heuer (kheuer2 at gwdg.de) ____ ___ _______
GWDG / __/______ ___ / _ )/ __/ _ \
Am Fassberg / _// __/ -_) -_) _ |\ \/ // /
37077 Goettingen /_/ /_/ \__/\__/____/___/____/
Germany
More information about the freebsd-questions
mailing list