News for hackers. Stuff that matters.
Re:Where do argc and argv come from? by FreeFull on Monday August 10, 2020 @03:16PM (#24112931)
It's a carryover from the MS-DOS days. One unfortunate part is that each program has to implement globs and any similar feature itself.
Re:Where do argc and argv come from? by frutiger on Monday August 10, 2020 @03:23PM (#24113006)
Even in a modern Unix, globs are expanded by the shell before invoking exec(3) with the individual arguments split out. They are not split/expanded by the C runtime.
Re:Where do argc and argv come from? by userbinator on Monday August 10, 2020 @03:45PM (#24113238)
...and I'm pretty sure DOS inherited it from CP/M.
Re:Where do argc and argv come from? by Someone on Monday August 10, 2020 @05:13PM (#24114059)
‘Implement’ isn’t necessary. That code could be provided by a shared library.

That could be the superior option. Moving command line expansion into a shared library gets rid of the problem where the command line with globs expanded is too long, could have standardized option handling earlier (that system-provided library for globbing could easily grow to handle option flags), could better handle file names containing spaces, etc.