From owner-freebsd-questions@FreeBSD.ORG Wed Apr 30 02:52:53 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 00A9937B401 for ; Wed, 30 Apr 2003 02:52:53 -0700 (PDT) Received: from gwdu60.gwdg.de (gwdu60.gwdg.de [134.76.98.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id B7E0743F75 for ; Wed, 30 Apr 2003 02:52:51 -0700 (PDT) (envelope-from kheuer2@gwdg.de) Received: from gwdu60.gwdg.de (localhost [127.0.0.1]) by gwdu60.gwdg.de (8.12.8p1/8.12.4) with ESMTP id h3U9qoij003522; Wed, 30 Apr 2003 11:52:50 +0200 (CEST) (envelope-from kheuer2@gwdg.de) Received: from localhost (kheuer2@localhost)h3U9qn46003519; Wed, 30 Apr 2003 11:52:49 +0200 (CEST) X-Authentication-Warning: gwdu60.gwdg.de: kheuer2 owned process doing -bs Date: Wed, 30 Apr 2003 11:52:49 +0200 (CEST) From: Konrad Heuer To: Gunnar Flygt In-Reply-To: <20030430093709.GA55280@sr.se> Message-ID: <20030430114216.L89463-100000@gwdu60.gwdg.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: FreeBSD Questions Subject: Re: problems with sh after upgrade to 4.7 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Apr 2003 09:52:53 -0000 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@gwdg.de) ____ ___ _______ GWDG / __/______ ___ / _ )/ __/ _ \ Am Fassberg / _// __/ -_) -_) _ |\ \/ // / 37077 Goettingen /_/ /_/ \__/\__/____/___/____/ Germany