Flags


Results 1 to 4 of 4

Thread: Flags

  1. #1
    Join Date
    Feb 2003
    Location
    Toronto
    Posts
    202

    Flags

    Hi,

    why do some man pages recommend using the -- before string flags?
    javac -classpath
    seems to work fine..

  2. #2
    Join Date
    Nov 2003
    Posts
    90
    Because some few options start with the same single character as string options

    -f
    --foo

    and the commandline interpreter will find -f and -foo to be the same thing.

  3. #3
    Join Date
    Feb 2003
    Location
    Toronto
    Posts
    202
    Thanks.. that explains it

  4. #4
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    It actually depends on whether the program uses getopt, getopt_long, getopt_long_only, or its own homegrown routine to parse its command line.

    getopt only recognizes single-character options, like -f.

    getopt_long recognizes both single-character options, like -f, and their equivalent long versions, like --foo. When the program uses getopt_long, -foo parses as "the -f option, with argument oo".

    getopt_long_only doesn't recognize short options at all. -foo and --foo are the same to it.

    If the argument-parsing routine is homegrown, then anything goes.

    I would actually guess, given the way that Sun does the rest of their JDK (and the fact that a JDK is required to compile the JDK...), that their argument parsing is homegrown. But that's only a guess.

    FWIW, most of the X toolkit arguments are single-dash as well (-display is probably the most common, followed by -geometry). I think Xlib uses a homegrown routine as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •