From owner-freebsd-questions@FreeBSD.ORG Mon Nov 5 12:03:06 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7EA9916A417 for ; Mon, 5 Nov 2007 12:03:06 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id D2BD413C480 for ; Mon, 5 Nov 2007 12:03:05 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (vader.bytemobile-rio.ondsl.gr [83.235.57.37]) (authenticated bits=128) by igloo.linux.gr (8.14.1/8.14.1/Debian-9) with ESMTP id lA5C1mhR010455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 5 Nov 2007 14:01:57 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.1/8.14.1) with ESMTP id lA5C1hhr009533; Mon, 5 Nov 2007 14:01:43 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.1/8.14.1/Submit) id lA5C1f9s009532; Mon, 5 Nov 2007 14:01:41 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 5 Nov 2007 14:01:41 +0200 From: Giorgos Keramidas To: Olivier Nicole Message-ID: <20071105120140.GD2093@kobe.laptop> References: <200711050703.lA573V3q013117@banyan.cs.ait.ac.th> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200711050703.lA573V3q013117@banyan.cs.ait.ac.th> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.99, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.41, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: freebsd-questions@freebsd.org Subject: Re: How to write a condition in Bourne shell X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Nov 2007 12:03:06 -0000 On 2007-11-05 14:03, Olivier Nicole wrote: > Hi, > > I am a lame Bourne sheel programmer, how to write: > > while [ ( $? -ne 0 ) -a ( $retry -gt 0 ) ] ; do > > that should execute as long as $? is not null and $retry is greater > than 0? Try something like... retry=0 done=-0 while [ $done -eq 0 ] && [ $retry -lt 10 ]; do run_some_other_stuff_here if [ $? -eq 0 ]; then done=1 fi done if [ $done -eq 0 ]; then echo "Failed after $retry attempts." fi