Re: [hackers] [sbase][PATCH] basename, dirname, printf: recognise -- and fail if options are used.
On 12/27/16, Evan Gateswrote: >> I respect your opinion and have to admit that this is not an easy >> discussion. Let's wait for some feedback and see what the others think >> about it. > > I side with Mattias on this one. Accepting -- even in utilities that > don't have flags has the benefits of 1) complying with POSIX so we can > be a drop in replacement 2) consistency with all the other tools. Actually, POSIX talks about '--' in guideline 10 of the Utility Syntax Guidelines[0] Many tools, for example cp, say The cp utility shall conform to XBD Utility Syntax Guidelines . But this is not mentioned for printf. So, the current implementation does comply with POSIX (at least in this respect). However, I did run into an issue with musl-cross-make which was passing '--' to printf. This has been fixed[1] in the latest release though. Are there many other places where scripts use -- with printf? Can we fix those instead? [0] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02 [1] https://github.com/richfelker/musl-cross-make/commit/3ac08b98c1c947043df489a760135ccb7f8b783d
Re: [hackers] [sbase][PATCH] basename, dirname, printf: recognise -- and fail if options are used.
On Tue, Dec 27, 2016 at 7:05 AM, Laslo Hunholdwrote: > On Tue, 27 Dec 2016 15:48:56 +0100 > Mattias Andrée wrote: > > Hey Mattias, > >> Okay, I personally do not agree with this and see echo(1) >> as an abomination, it treats any unrecognised flags as >> strings, but if had debate on it, keep to want you agreed >> to. I agree echo is an abomination. Especially with POSIX saying things like "If the first operand is -n, or if any of the operands contain a character, the results are implementation-defined." The best thing we can do is not use echo in any scripts. I think from a philosophical standpoint sbase echo should not include -n, to be simpler and still POSIX compliant. However pragmatically many scripts use echo -n so I think it makes sense to keep it. > > I respect your opinion and have to admit that this is not an easy > discussion. Let's wait for some feedback and see what the others think > about it. I side with Mattias on this one. Accepting -- even in utilities that don't have flags has the benefits of 1) complying with POSIX so we can be a drop in replacement 2) consistency with all the other tools.
Re: [hackers] [sbase][PATCH] basename, dirname, printf: recognise -- and fail if options are used.
On Tue, 27 Dec 2016 15:48:56 +0100 Mattias Andréewrote: Hey Mattias, > Okay, I personally do not agree with this and see echo(1) > as an abomination, it treats any unrecognised flags as > strings, but if had debate on it, keep to want you agreed > to. I respect your opinion and have to admit that this is not an easy discussion. Let's wait for some feedback and see what the others think about it. Cheers Laslo -- Laslo Hunhold
Re: [hackers] [sbase][PATCH] basename, dirname, printf: recognise -- and fail if options are used.
On Tue, 27 Dec 2016 15:26:09 +0100 Mattias Andréewrote: Hey Mattias, > POSIX explicitly states that echo(1) shall treat “--” > as a string operand and not as a delimiter. My guess > is that this is for historical reason, much like the > existence of echo(1) itself. ah now I remember, thanks. You know, sbase takes the liberty of moving away from Posix where consistency is a concern. In this case I think our result from a long debate was to say: Well, we just treat "--" as a normal string for tools that do not accept any flags. For instance, if echo does not interpret --, why doesn't printf also follow echo in this behaviour? Cheers Laslo -- Laslo Hunhold
Re: [hackers] [sbase][PATCH] basename, dirname, printf: recognise -- and fail if options are used.
On Tue, 27 Dec 2016 15:21:11 +0100 Laslo Hunholdwrote: > On Tue, 27 Dec 2016 15:14:44 +0100 > Mattias Andrée wrote: > > Hey Mattias, > > > POSIX says “--” should be supported unless stated > > otherwise. I interpret that standard saying that this > > also applies utilities that do not take any flags. And > > to be on the safe side I think it is a good idea to > > support “--” for two reasons: (1) existing scripts may > > require it, and (2) if POSIX adds a flag to the utility > > in the future we must support “--” now, otherwise > > compatibility will be broken. > > so what about "echo --"? > > Cheers > > Laslo > POSIX explicitly states that echo(1) shall treat “--” as a string operand and not as a delimiter. My guess is that this is for historical reason, much like the existence of echo(1) itself. pgpkMrgLX4Pr4.pgp Description: OpenPGP digital signature
Re: [hackers] [sbase][PATCH] basename, dirname, printf: recognise -- and fail if options are used.
On Tue, 27 Dec 2016 15:14:44 +0100 Mattias Andréewrote: Hey Mattias, > POSIX says “--” should be supported unless stated otherwise. > I interpret that standard saying that this also applies utilities > that do not take any flags. And to be on the safe side I think > it is a good idea to support “--” for two reasons: (1) existing > scripts may require it, and (2) if POSIX adds a flag to the > utility in the future we must support “--” now, otherwise > compatibility will be broken. so what about "echo --"? Cheers Laslo -- Laslo Hunhold
Re: [hackers] [sbase][PATCH] basename, dirname, printf: recognise -- and fail if options are used.
On Tue, 27 Dec 2016 11:26:07 +0100 Laslo Hunholdwrote: > On Fri, 25 Mar 2016 21:31:37 +0100 > Mattias Andrée wrote: > > Hey Mattias, > > > basename.c | 5 - > > dirname.c | 6 +- > > printf.c | 12 > > 3 files changed, 17 insertions(+), 6 deletions(-) > > I do not support this patch, as "--" only makes sense for > tools that actually take flags. > I pity that GNU basename(1), dirname(1) and printf(1) > take flags, however, see great value in being able to do > > $ printf -- > > and get what you asked for instead of some error message > > printf: usage: printf [-v var] format [arguments] > > Cheers > > Laslo > POSIX says “--” should be supported unless stated otherwise. I interpret that standard saying that this also applies utilities that do not take any flags. And to be on the safe side I think it is a good idea to support “--” for two reasons: (1) existing scripts may require it, and (2) if POSIX adds a flag to the utility in the future we must support “--” now, otherwise compatibility will be broken. pgpNxFM3rLXhu.pgp Description: OpenPGP digital signature