Jump to content

Talk:Command-line argument parsing

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Title of this article confusing

[edit]

Reading about "parsing" I expected to read something about parsing command line arguments, probably in different programming languages, for example pointers to libraries that simplify this task for the most common conventions for the syntax of command lines. However, this article seems only to show how to access and iterate through the command line in different programming language. So at this point in time a less confusing title probably was "Command-line argument processing". — Preceding unsigned comment added by Pia F. Bichsel (talkcontribs) 10:18, 27 January 2016 (UTC)[reply]

Why this article doesn't make much sense and should either be reworked completely or deleted

[edit]
  • The overall method used to parse command-line arguments is not a question of any particular programming language. For example, if you want your program to parse command-line arguments in a POSIX-compliant way, then the parser needs to do what POSIX specifies, regardless of the language it is written in. The language-specific part is merely how to accomplish what the specification says in $language.
  • In the examples for C, Bash, Perl and Python, there is exactly zero parsing going on. Parsing means syntactical analysis, not merely printing back user input. The example for Bash doesn't offer anything but an example of how user input should not be handled (unquoted substitutions), which is why I will remove it in a minute. If you want to know something about parsing command-line arguments in Bash, see, for example: https://mywiki.wooledge.org/BashFAQ/035.

For a sane approach to saying something about parsing command-line arguments in general, you could have a look at something I have written about that topic recently: https://www.msiism.org/blog/2019/03/10/how-to-parse-command-line-arguments.html (Note that the article is not published under a free content license.) Msiism (talk) 20:37, 13 March 2019 (UTC)[reply]