[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#48247: echo -n



Let me state once again, this has no bearing whatsoever over the proposed
change in policy and my question about whether escape codes/-e are to be
mentioned or not.  It is for purely pendantic value.

On Mon, Oct 25, 1999 at 07:24:59AM -0400, Raul Miller wrote:
> Except you elected to not quote what posix said about options:
> 
> <quote>
>  4.19.3  Options
> 
>  The echo utility shall not recognize the -- argument in the manner
>  specified by utility syntax guideline 10 in 2.10.2; -- shall be
>  recognized as a string operand.
> 
>  Implementations need not support any options.
> </quote>

The last line is a big vague, but I don't see how this allows options:

Firstly the synopsis:

 echo  [string ...]

2.10.1 says that this means that everything that comes after echo are
operands, no options at all.

Then if you go down to the rationale of echo, the fact that the line in the
Options section does not imply that options that change the behaviour of
echo are permitted becomes a lot clearer:

 The echo utility does not support utility syntax guideline 10 because
 existing applications depend on echo to echo all of its arguments, except
 for the -n option in the BSD version.

So that means the intent here is to enforce all conforming implementations of
echo to echo all its arguments unless the first operand is -n.  This is
exactly what the Operands section says.

> So the interpretation you're suggesting is *legal* for a POSIX
> implementation of /bin/sh, but it's fairly clear that it's not
> *required* for a POSIX implementation of /bin/sh

I believe it's required.  Please check with the relevant authorities.

> It's fairly clear from 2.10.1 that options are not operands.  [Also note
> the parts of 2.10.2 which were not explicitly superceeded in 4.19.]

The synopsis and the Operands section indicate otherwise.  The guidelines
certainly does not imply that options are permitted in this case.  In any
case, the guidelines only have "should" and not "shall" unless the utility
claims conformance to those guidelines, which echo does not.

> If options are forbidden by posix it's reasonable to expect that
> the command must support their treatment as operands.  However
> when they're merely not required it's reasonable for that to vary
> from one system to another.

My reading of it is that options are forbidden.  However, if the first operand
is -n or there are backslashes, anything can occur.
-- 
Debian GNU/Linux 2.1 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Reply to: