[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: expr bug
From: |
Bob Proulx |
Subject: |
Re: expr bug |
Date: |
Mon, 23 May 2005 20:48:12 -0600 |
User-agent: |
Mutt/1.5.9i |
Bob Gill wrote:
> Hi. I think I found a bug in expr (and I haven't checked your bug
> tracker and therefore apologize in advance if it's already been
> reported/fixed). The bug: in expr, the product function appears to be
> broken. Example:
> />expr 5 * 2
> expr: syntax error
Thanks for reporting this. But you have hit a common
misunderstanding. The '*' character is a special character to the
command shell. It expands to match filenames. Therefore your above
command is really something completely different than you think it
is. Try this:
echo expr 5 * 2
What does that show? You will see it matching to filenames and so you
see the syntax error. You need to quote shell metacharacters to
prevent them from being modified by the shell.
expr 5 \* 2
or
expr 5 '*' 2
The man page carries this text:
Beware that many operators need to be escaped or quoted
for shells.
> ...the problem only occurs with product. Sum, difference, quotient all
> work as expected, as shown here:
> />expr 4 + 2
> 6
> />expr 4 - 2
> 2
> />expr 4 / 2
> 2
None of those are special to the shell.
> The bug is for expr version 5.2.1, running on a GNU/Linux system, and
> the man page directed the bug reports to you.
You did good. Thanks for the report. But this is just well known
shell behavior.
Bob
- expr bug, Bob Gill, 2005/05/23
- Re: expr bug,
Bob Proulx <=