[hackers] [PATCH] Update macros in arg.h to not cause hidden side effects to argv or rely on previously defined variables.

2024-08-28 Thread sebastien peterson boudreau
I mainly wanted to gauge interest in this change by sending it. I was looking at the macros in arg.h and comparing to the POSIX `getopt`, but what I disliked is that `ARGBEGIN` mutates `argv` and relies on the variable `argv0` being previously defined. Of course, this is also an issue with `ge

Re: [hackers] [PATCH] Update macros in arg.h to not cause hidden side effects to argv or rely on previously defined variables.

2024-08-28 Thread Mattias Andrée
ARGBEGIN...ARGEND is used to parse AND consume the options (and it also consumes argv[0]), leaving the operands in argv for the code below ARGEND. That's why mutates argv and argc. Now the code below ARGEND has no idea which elements in argv are options and which elements are operands. On Wed, 28