Date: Mon, 30 Sep 1996 13:01:07 -0400 From: "Gary Chrysler" <tcg@ime.net> To: "Thomas David Rivers" <ponds!ponds!rivers>, <ponds!ponds!freebsd.org!questions> Subject: Re: sh shell script help needed! Message-ID: <199609301701.NAA24054@ime.net>
next in thread | raw e-mail | index | archive | help
I thank you for the explanation, Though it turned out to be
the fact that I use a csh (tcsh) shell.
The addition of: #!/bin/sh, Solved my troubles!
The missing ';' was actually a typo.
-Enjoy
Gary
~~~~~~~~~~~~~~~~
Improve America's Knowledge... Share yours
The Borg... Where minds meet
(207) 929-3848
----------
> From: Thomas David Rivers <ponds!rivers@dg-rtp.dg.com>
> To: tcg@ime.net; ponds!freebsd.org!questions@dg-rtp.dg.com
> Subject: Re: sh shell script help needed!
> Date: Monday, September 30, 1996 9:16 AM
>
> >
> >
> > What am I doing wrong here?? (Yes, I know it's me :)
> > Such a simple thing and I can't get it to work!
> >
> > # test script
> > # based on /etc/rc usage of if
> > if [ $1 = yes ] then
>
> Here's your problem..
>
> the 'then' part of an 'if' must be on a separate 'line'. This can be
> accomplished by physically moving the then to the next line (which is
> what I prefer) or by inserting the ';' separator...
>
> As in:
>
> if [ $1 = yes ]
> then
> echo Yes
> fi
>
> or
>
> if [ $1 = yes ] ; then
> echo Yes
> fi
>
>
> Now, your next question should be "That seems pretty dumb - why is it
so?"
>
> The problem is that (logically, if not actually) the 'if' statement
> actually runs a program, in this instance, a program named '[' which is
> a link to a program named 'test'. This program is presumed to accept
> arguments, which are in your case "$1 = yes ]". (Note that ']' is not
> the close of '[', it is an (ignored) argument to the 'test' program.)
>
> So, the shell needs to determine when the arguments are over, and
> where the 'then' is. You do that by inserting a command separator (the
';')
> or by putting the 'then' on the next line.
>
> Hope this helps
>
> - Dave Rivers -
>
> > ramillia {1377} ./test yes
> > if: Expression Syntax
> > ramillia {1378}
> >
> > Such an easy thing... ... I've tried every variation I can think of
while
> > crusing through stuff in /etc
> >
> > Thanks.
> >
> > -Enjoy
> > Gary
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609301701.NAA24054>
