On 4/5/06, Legatus <[EMAIL PROTECTED]> wrote:
> Carl Lowenstein wrote:
> > Since when has one been able to put a "-" option after the file name
> > in a command line?
> >
> > [EMAIL PROTECTED] tmp]$ mkdir a
> > [EMAIL PROTECTED] tmp]$ touch a/b
> > [EMAIL PROTECTED] tmp]$ rm a
> > rm: cannot remove `a': Is a directory
> > [EMAIL PROTECTED] tmp]$ rm a -rf
> > [EMAIL PROTECTED] tmp]$ ls a
> > ls: a: No such file or directory
> > [EMAIL PROTECTED] tmp]$ rm --version
> > rm (coreutils) 5.2.1
> >
>
> You can do that with pretty much all the fileutils
Well, a careful reading of getopt(3) says "you can do that with
anything that processes its command line through getopt".
- - - - - - -
The getopt() function parses the command line arguments. Its argu-
ments argc and argv are the argument count and array as passed to the
main() function on program invocation. An element of argv that starts
with '-' (and is not exactly "-" or "--") is an option element. The
characters of this element (aside from the initial '-') are option
characters. If getopt() is called repeatedly, it returns successively
each of the option characters from each of the option elements.
. . .
By default, getopt() permutes the contents of argv as it scans, so
that eventually all the non-options are at the end.
- - - - - - -
So getopt(3) rationalizes the command line, pulling out the options
first and leaving everything else (e.g. file name) for last. Still
doesn't feel right to fingers that have been typing Unix commands for
much of the last 30 years. And I am sure that the original SysV
getopt did not do this either.
carl
--
carl lowenstein marine physical lab u.c. san diego
[EMAIL PROTECTED]
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list