From owner-freebsd-questions@FreeBSD.ORG Wed Jan 3 21:50:50 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CAC5E16A403 for ; Wed, 3 Jan 2007 21:50:50 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout5.cac.washington.edu (mxout5.cac.washington.edu [140.142.32.135]) by mx1.freebsd.org (Postfix) with ESMTP id 8E41813C4AB for ; Wed, 3 Jan 2007 21:50:50 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.33.9] (may be forged)) by mxout5.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW06.09) with ESMTP id l03Loniv024266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Jan 2007 13:50:50 -0800 X-Auth-Received: from [192.168.0.101] (dsl254-013-145.sea1.dsl.speakeasy.net [216.254.13.145]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.7+UW06.06/8.13.7+UW06.09) with ESMTP id l03LontE031146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 3 Jan 2007 13:50:49 -0800 Message-ID: <459C2538.3070304@u.washington.edu> Date: Wed, 03 Jan 2007 13:50:48 -0800 From: Garrett Cooper User-Agent: Thunderbird 1.5.0.9 (X11/20061226) MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <17820.3343.799303.349686@jerusalem.litteratus.org> <20070103211852.GB60153@gizmo.acns.msu.edu> <1d3ed48c0701031332p6bfa4a23l9e19d164289dd12@mail.gmail.com> In-Reply-To: <1d3ed48c0701031332p6bfa4a23l9e19d164289dd12@mail.gmail.com> X-Enigmail-Version: 0.94.1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-PMX-Version: 5.2.2.285561, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.1.3.133933 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __LINES_OF_YELLING 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' Subject: Re: OT: stupid sh scripting question 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: Wed, 03 Jan 2007 21:50:50 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kevin Downey wrote: > On 1/3/07, Jerry McAllister wrote: >> On Wed, Jan 03, 2007 at 03:07:43PM -0500, Robert Huff wrote: >> >> > >> > This is probably staring me in the face: >> > >> > if [ ! -d "foo"] >> > then mkdir foo >> > fi >> > >> > gives me: >> > >> > [: missing ] >> >> It is probably not telling you ':' missing but ';' missing. >> It goes after the ']', plus I think the space before ']' is required. >> >> ////jerry >> >> > >> > Looking at rc.subr I see: >> > >> > if [ ! -d "$linkdir" ]; then >> > warn "$_me: the directory $linkdir does not exist." >> > return 1 >> > fi >> > >> > >> > Robert Huff > > the ';' is not required if the 'then' statement is not on the same > line as the 'if' statement. > > kpd@zifnab ~% sh > $ if echo foo >> then >> echo bar >> fi > foo > bar Right. As many people have said on the list already, the only issue with the original script is with the lack of a space between the last quote for "foo" and "]". test(1) likes having that extra space and will not work properly without it. - -Garrett -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.1 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFnCU4EnKyINQw/HARAhLZAJsG0Wk9t9RjzieA3u/EPWK3Dynv2ACcCRGZ 0e8eCk+ScQnqNrAMHrgIuZc= =rh5F -----END PGP SIGNATURE-----