Bug 431005 - parse_long_options doesn't respect "--"
Summary: parse_long_options doesn't respect "--"
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: coreutils
Version: 4.8
Hardware: All
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Ondrej Vasik
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-01-31 01:49 UTC by A. Non
Modified: 2010-02-22 12:35 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-02-22 12:35:52 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description A. Non 2008-01-31 01:49:02 UTC
Description of problem:
I think that parse_long_options() in long-options.c is broken in a few very
minor ways.

There appears to be no way for echo to print out the string "-n" or "--help" or
the other things that happen to be options because it doesn't respect "--" like
most other things do.

The fact that parse_long_options() looks at argc when deciding whether to parse
options is also kind of strange and leads to this funny error:
% sleep --help --version
sleep: unrecognized option `--help'
Try `sleep --help' for more information.

The fact that I can't get yes to repeatedly print out "--help" is odd but not a
huge issue.  The fact that echo can't print out a literal "-n" seems like it
might be a (minor) problem, though.


Version-Release number of selected component (if applicable):
GNU coreutils 5.2.1
The unnecessary argc check seems to still be in the source code for coreutils 6.10.

How reproducible:
Always reproducible via "sleep --help --version" or "echo -- -n"

Actual results:
"echo -- -n" prints out "-- -n" instead of "-n"

Expected results:
"-n"

Comment 1 Ondrej Vasik 2008-01-31 16:56:20 UTC
Fixed and built as coreutils-6.10-4.fc9 in fedora RAWHIDE branch. 

Comment 2 Ondrej Vasik 2008-03-13 11:00:06 UTC
Well, echo change was not accepted by upstream (as not justified and potentially
breaking scripts), so I will remove that functionality from Fedora in next
coreutils builds. In fact you could use POSIXLY_CORRECT env.variable or printf 
command for such things. POSIX says do not use any options in echo. So that one
part is NOTABUG (full thread on upstream mailing list is
http://lists.gnu.org/archive/html/bug-coreutils/2008-03/msg00111.html)...

Comment 3 Michael Cronenworth 2008-03-28 14:40:41 UTC
Thanks for reverting this. This did break scripts, at least for me.

The only reason I knew this was changed was from the RPM changelog. I didn't see
any mention of you reverting this in the changelog, but my scripts work now.


Note You need to log in before you can comment on or make changes to this bug.