Bug #1237
closedpatch to add getopt parsing to expr
0%
Description
Here's a patch to add getopt(3) support to expr so that -- is accepted as
required by POSIX. This was pointed out by vstemen on IRC. I'll
commit sometime after the release if there are no objections.
Joe
Files
Updated by joerg almost 16 years ago
The use of getopt here is wrong. Besides, using getopt is taking a
sledgehammer to crack a nut. Attached is the corresponding fix for
NetBSD, the explicit check for having at least one argument is better
anyway.
Joerg
Updated by josepht almost 16 years ago
Since POSIX requires arguments beginning with '-' to be options
shouldn't the following result in an error?
expr -d=zzz : '.*=\(.*\)'
Where:
expr -- -d=zzz : '.*=\(.*\)'
should be the correct usage. I opted to use getopt() since FreeBSD's
expr accepts e. The "" was inadvertently left in the patch.
Thanks,
Joe
Updated by joerg almost 16 years ago
No. POSIX only says that -- has to be supported to disable the use of
options. It doesn't say that options have to be used.
Joerg
Updated by josepht almost 16 years ago
What about this?
Guideline 14:
If an argument can be identified according to Guidelines 3 through
10 as an option, or as a group of options without option-arguments
behind one '-' delimiter, then it should be treated as such.
Joe
Updated by joerg almost 16 years ago
Doesn't apply. SUS leaves it open whether or not expr supports options.
It does require expr to support --. Consider "expr -1".
Joerg
Updated by swildner over 15 years ago
was committed -> ee2af4a46fc2ddef3a589ee9d5b58aa1c1f923bc