diff mbox series

[1/2] exec: type: ignore first --, per POSIX

Message ID b9085f1a9812a436d37bc6f8d96d17bdba4433c5.1670966008.git.nabijaczleweli@nabijaczleweli.xyz (mailing list archive)
State Rejected
Delegated to: Herbert Xu
Headers show
Series [1/2] exec: type: ignore first --, per POSIX | expand

Commit Message

наб Dec. 13, 2022, 9:13 p.m. UTC
Issue 7, XCU, type, OPTIONS reads "None.",
and type isn't a special built-in listed in sexion 2.14 ‒
this means that XCU, 1. Introduction, 1.4 Utility Description Defaults,
OPTIONS, Default Behavior applies:
  Default Behavior: When this section is listed as "None.", it means
  that the implementation need not support any options. Standard
  utilities that do not accept options, but that do accept operands,
  shall recognize "--" as a first argument to be discarded.

Test with: type -- ls --
Correct output lists ls=/bin/ls, then --=ENOENT
Wrong output lists --=ENOENT, ls=/bin/ls, --=ENOENT

Fixes: https://bugs.debian.org/870317
---
 src/exec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Herbert Xu Jan. 2, 2023, 9:19 a.m. UTC | #1
наб <nabijaczleweli@nabijaczleweli.xyz> wrote:
> [-- text/plain, encoding quoted-printable, charset: utf-8, 41 lines --]
> 
> Issue 7, XCU, type, OPTIONS reads "None.",

type is marked XSI.  dash does claim conformance with respect
to XSI.

Thanks,
наб Jan. 2, 2023, 12:46 p.m. UTC | #2
On Mon, Jan 02, 2023 at 05:19:17PM +0800, Herbert Xu wrote:
> наб <nabijaczleweli@nabijaczleweli.xyz> wrote:
> > Issue 7, XCU, type, OPTIONS reads "None.",
> type is marked XSI.  dash does claim conformance with respect
> to XSI.
Which means it ought to abide by "None." in the OPTIONS sexion,
as out-lined in the subsequent lines, i.e. discard an initial --, yes.

Good to see we agree, I guess?
наб
Harald van Dijk Jan. 2, 2023, 1:34 p.m. UTC | #3
On 02/01/2023 12:46, наб wrote:
> On Mon, Jan 02, 2023 at 05:19:17PM +0800, Herbert Xu wrote:
>> наб <nabijaczleweli@nabijaczleweli.xyz> wrote:
>>> Issue 7, XCU, type, OPTIONS reads "None.",
>> type is marked XSI.  dash does claim conformance with respect
>> to XSI.
> Which means it ought to abide by "None." in the OPTIONS sexion,
> as out-lined in the subsequent lines, i.e. discard an initial --, yes.
> 
> Good to see we agree, I guess?

I'm pretty sure that was a pretty bad typo and meant to say "dash does 
*not* claim conformance with respect to XSI." See e.g. 
<https://lore.kernel.org/dash/20130904032000.GA19583@gondor.apana.org.au/>, 
"In any case, dash does not claim XSI conformance, [...]"

Cheers,
Harald van Dijk
Herbert Xu Jan. 3, 2023, 1:39 a.m. UTC | #4
On Mon, Jan 02, 2023 at 01:46:28PM +0100, наб wrote:
> On Mon, Jan 02, 2023 at 05:19:17PM +0800, Herbert Xu wrote:
> > наб <nabijaczleweli@nabijaczleweli.xyz> wrote:
> > > Issue 7, XCU, type, OPTIONS reads "None.",
> > type is marked XSI.  dash does claim conformance with respect
> > to XSI.
> Which means it ought to abide by "None." in the OPTIONS sexion,
> as out-lined in the subsequent lines, i.e. discard an initial --, yes.
> 
> Good to see we agree, I guess?

Sorry, I meant that dash does not claim conformance.

Cheers,
наб Jan. 3, 2023, 12:40 p.m. UTC | #5
Hi!

On Tue, Jan 03, 2023 at 09:39:17AM +0800, Herbert Xu wrote:
> On Mon, Jan 02, 2023 at 01:46:28PM +0100, наб wrote:
> > On Mon, Jan 02, 2023 at 05:19:17PM +0800, Herbert Xu wrote:
> > > наб <nabijaczleweli@nabijaczleweli.xyz> wrote:
> > > > Issue 7, XCU, type, OPTIONS reads "None.",
> > > type is marked XSI.  dash does claim conformance with respect
> > > to XSI.
> > Which means it ought to abide by "None." in the OPTIONS sexion,
> > as out-lined in the subsequent lines, i.e. discard an initial --, yes.
> > Good to see we agree, I guess?
> Sorry, I meant that dash does not claim conformance.

If I can't convince you to apply this with the consistency argument of
"all built-ins that could, would parse their arguments with nextopt()",
then do consider the 2/2 that does the same for getopts,
which isn't shaded XSI and therefore must support this.

Best,
наб
Herbert Xu Jan. 4, 2023, 2:10 a.m. UTC | #6
On Tue, Jan 03, 2023 at 01:40:52PM +0100, наб wrote:
>
> If I can't convince you to apply this with the consistency argument of

If you can rephrase the patch description to not refer to
POSIX then I'm happy with your patch for type(1).

Thanks,
diff mbox series

Patch

diff --git a/src/exec.c b/src/exec.c
index 87354d4..d61881d 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -760,11 +760,11 @@  unsetfunc(const char *name)
 int
 typecmd(int argc, char **argv)
 {
-	int i;
 	int err = 0;
 
-	for (i = 1; i < argc; i++) {
-		err |= describe_command(out1, argv[i], NULL, 1);
+	nextopt(nullstr);
+	while (*argptr) {
+		err |= describe_command(out1, *argptr++, NULL, 1);
 	}
 	return err;
 }