From owner-freebsd-questions@freebsd.org Wed Nov 8 12:57:11 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1579FE52BE0 for ; Wed, 8 Nov 2017 12:57:11 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mailrelay15.qsc.de (mailrelay15.qsc.de [212.99.187.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.antispameurope.com", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 72BDF7970B for ; Wed, 8 Nov 2017 12:57:09 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de ([213.148.129.14]) by mailrelay15.qsc.de; Wed, 08 Nov 2017 13:57:00 +0100 Received: from r56.edvax.de (port-92-195-23-159.dynamic.qsc.de [92.195.23.159]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id EE78E3CBF9; Wed, 8 Nov 2017 13:56:59 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id vA8Cuxgl002225; Wed, 8 Nov 2017 13:56:59 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Wed, 8 Nov 2017 13:56:59 +0100 From: Polytropon To: Trond =?ISO-8859-1?Q?Endrest=F8l?= Cc: freeBSD Mailing List Subject: Re: how to code a timer loop in a sh script Message-Id: <20171108135659.dab81adf.freebsd@edvax.de> In-Reply-To: References: <5A00A826.2000501@gmail.com> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-cloud-security-sender: freebsd@edvax.de X-cloud-security-recipient: freebsd-questions@freebsd.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mailrelay15.qsc.de with 535126E4420 X-cloud-security-connect: mx01.qsc.de[213.148.129.14], TLS=1, IP=213.148.129.14 X-cloud-security: scantime:.1594 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2017 12:57:11 -0000 On Wed, 8 Nov 2017 08:25:55 +0100 (CET), Trond Endrest=F8l wrote: > On Mon, 6 Nov 2017 19:24+0100, Michael Schuster wrote: >=20 > > while [ 1 ]; do > > do_stuff > > sleep 600 > > done >=20 > This should be even better: >=20 > while true; do > do_stuff > sleep 600 > done Yes. While /usr/bin/true always evaluates to true (as desired), "test 1" depends on if it's an internal or external command which depends on the shell, and if the implementation conforms to the standard. In this specific case, 1 would be seen as "1", a non-empty string, and therefore should cause test to return 0, as a non-empty string evaluates to true. >From "man test": string True if string is not the null string. As the 1 is the only expression tested, this rule applies. No math included. ;-) --=20 Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...