-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Please keep replies on the list, so that others may chime in.
According to Rich Felker on 11/26/2007 9:41 PM: >>> $ printf ---%s---\\n test >>> bash: printf: --: invalid option >> That's not a bug. If you insist on printing with a format string that >> starts with -, POSIX requires that you use -- to end arguments, as in: >> >> $ printf -- ---%s---\\n test >> - ---test--- >> >> If your non-builtin system printf behaves differently, that is a bug in >> your system printf. > > This is simply not true. Read the synopsis for POSIX printf. It does > not support options; usage is simply: > > printf format [argument ...] POSIX merely states that a _conforming_ program cannot use any options; however, it does not forbid the presence of options as extensions. Furthermore, it states: http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html 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. The utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 that claim conformance to these guidelines shall conform completely to these guidelines as if these guidelines contained the term "shall" instead of "should". > Using printf -- ---%s---\\n test is not valid at all and will produce > unspecified output since there are no format specifiers in the format > ("--") and yet there are arguments to be formatted. You are wrong. It is the _only_ POSIX-sanctioned way to print with a format string starting with a hyphen, because the -- is required to be interpreted as the end of options, and not as the format string. The format string is not an option, so it is the first word after the end-of-options designator, or ---%s---\\n. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHS6Mc84KuGfSFAYARAhFkAKDLLWTgc7VtWY2JwkqRZidifdg/kwCfZc3Y Fw8/X5o8vWEjommtHozp8mY= =cH3R -----END PGP SIGNATURE-----