Benjamin Kaplan wrote:
On Mon, Aug 16, 2010 at 11:33 PM, kreglet <kreg...@gmail.com> wrote:
desktop:~/bin$ modtest.py
desktop:~/bin$ evenodd(45)
bash: syntax error near unexpected token `45'
And this is what's supposed to happen any time you try this in any
shell. When you call evenodd, bash looks for a program or shell
built-in called evenodd. Which doesn't exist.
That's not what "syntax error means". If the problem were that
evenodd does not exist as a shell function, the error would have
been "bash: evenodd: command not found".
I do not understand why bash says the token `45' is unexpected.
The '(' token is the problem. It's a syntax error because in
bash syntax function arguments are not enclosed in parentheses:
$ function evenodd {
> if (( $1 % 2 ))
> then echo $1 is odd
> else echo $1 is even
> fi
> }
$ evenodd 45
45 is odd
$ evenodd(45)
bash: syntax error near unexpected token `45'
$
Of course, this is completely off-topic.
-- HansM
--
http://mail.python.org/mailman/listinfo/python-list