Email List: Xaustin-review-lX
[All Lists]

Re: Defect in XBD Utility Syntax Guidelines

To: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx, yyyyyy@xxxxxxxxxxx
Subject: Re: Defect in XBD Utility Syntax Guidelines
From: Glenn Fowler <yyy@xxxxxxxxxxxxxxxx>
Date: Wed, 29 Sep 2004 01:13:19 -0400 (EDT)
Organization: AT&T Labs Research
References: <200409282347.AAA01226@xxxxxx>
On Wed, 29 Sep 2004 00:47:40 +0100 (BST) yyyyyy@xxxxxxxxxxx wrote:
>       Defect report from : Paul Eggert , UCLA

> Nowhere do the Utility Syntax Guidelines explicitly say that the
> first operand cannot begin with "-" unless it is the single
> character "-".

From 12.1 Utility Argument Syntax:

  The notation used for the SYNOPSIS sections imposes requirements on the
  implementors of the standard utilities and provides a simple reference
  for the application developer or system user.

  1.The utility in the example is named utility_name. It is
    followed by options, option-arguments, and operands. The
    arguments that consist of hyphens and single letters or
    digits, such as 'a', are known as "options" (or,
    historically, "flags"). Certain options are followed by an
    "option-argument", as shown with [ -c option_argument]. The
    arguments following the last options and option-arguments are
    named "operands".

  7.Arguments or option-arguments enclosed in the '[' and ']'
    notation are optional and can be omitted. Conforming
    applications shall not include the '[' and ']' symbols in
    data submitted to the utility.

From 12.2 Utility Syntax Guidelines:

  Guideline 4: 
     All options should be preceded by the '-' delimiter character. 
  Guideline 9: 
     All options should precede operands on the command line.
  Guideline 10: 
     The argument -- should be accepted as a delimiter indicating
     the end of options. Any following arguments should be treated
     as operands, even if they begin with the '-' character. The --
     argument should not be used as an option or as an operand. 

From these one can infer general utility arguments concepts:

  there can be 0 or more option arguments
  an option argument begins with the '-' delimiter character
  option arguments precede operand arguments
  there can be 0 or more operand arguments
  if one or more options are specified then there is a "last option";
     the operand arguments follow the "last option"
  an argument beginning with a '-' and preceded by an option
     or option-argument is an option; if the intention is to
     treat it as an operand then it must be preceded by a "--"
     argument

So, given "ls -l -d foo" and -l and -d are flags (no option-arguments):
    -l is an option
    -d is an option
    the last option is -d
    foo is an operand

<Prev in Thread] Current Thread [Next in Thread>