On Wed, 11 Dec 2002, dbrett wrote:

> Nope, unless I missed what you trying to get at.
> 
> #!/bin/bash
> 
> if [$1 == '']; then
>         echo ''
>         echo "format is $0 'math equation'"
>         echo "i.e. $0 (2+2)*3"
>         echo ''
>         exit
> fi
> 
> echo $1 | /usr/bin/bc -l  2>&1 /dev/null
> 
> Here is the output
> ./math "2 + 3 *( 5 - 3 )"  <---command
> 
> ./math: [2: command not found
> 8

ok, this is getting just plain silly.  first, if you have a
conditional test in a script, the "[" character *must* be
delimited by white space.  why?  because it's a *command*.
yes, that's right.  if you don't believe me, try

$ type [

this is actually comprehensible if you understand that the
"if" construct in a shell script can test *only* the return
code from commands, and that's it.  hence the rationale for
[ actually being a command.  hence the absolute need for the
surrounding whitespace.

next issue.  () are shell metacharacters -- they are used
to surround one or more commands that are to be run inside
a subshell.  use them sparingly and wisely.

but more to the point, what exactly are you trying to do 
here?  i suspect this can all be done in about two lines.
and i'm pretty sure i can figure out what those two lines
are if i knew what you were after.

rday





-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to