Date: Wed, 03 Jan 2007 13:50:48 -0800 From: Garrett Cooper <youshi10@u.washington.edu> To: freebsd-questions@freebsd.org Subject: Re: OT: stupid sh scripting question Message-ID: <459C2538.3070304@u.washington.edu> In-Reply-To: <1d3ed48c0701031332p6bfa4a23l9e19d164289dd12@mail.gmail.com> References: <17820.3343.799303.349686@jerusalem.litteratus.org> <20070103211852.GB60153@gizmo.acns.msu.edu> <1d3ed48c0701031332p6bfa4a23l9e19d164289dd12@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kevin Downey wrote: > On 1/3/07, Jerry McAllister <jerrymc@msu.edu> 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-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?459C2538.3070304>