expr, shell interprets symbols
Rick Graham <[email protected]> Thu, 20 Jun 2002 01:34:07 -0400 (EDT)
| Newsgroups | gmane.comp.gnu.sh-utils.bugs |
|---|---|
| Message-ID | <[email protected]> |
ISSUE, BUG IN EXPR:
DISCUSSION:
The shell interprets symbols like ( ) * > before expr gets its command line.
I know this isn't news to anyone so I guess it's not considered a bug.
I think it is a bug since it corrupts ease of use of this utility.
SUGGESTED SOLUTION:
Allow expressions to be passed as strings with a command line switch to force
evaluation as an expression.
example
expr -e "( 128 + 64 + 16 ) * 4"
This could be very simply implemented in two ways:
1: pre-evaluate the command line expand ARGV out into a new string array and count
for evaluation when strings are switched.
2: do a straight copy of ARGV replacing -e with a NOP and the string with the result
of its evaluation.
It would also be nice if eval accepted input from stdin.
I might be willing to do this if I thought the result would be part of the gnu suite.
Cheers!
Rick
[email protected]